Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lamps/password policy #169

Merged
merged 6 commits into from
May 19, 2015
Merged

Lamps/password policy #169

merged 6 commits into from
May 19, 2015

Conversation

adevitt-r7
Copy link
Contributor

GEM changes required for NEX-43065: [Password Policy Administration] Customized Password Policies.

@@ -0,0 +1,69 @@
module Nexpose
require 'json'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed here. As lib/nexpose.rb takes care of it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree. It's good practice to require anything used within the same file. We don't do it much in the gem today, but if we moved to it we could start doing things like lazy loading files.

It's a matter of debate, but it's perfectly harmless to leave since it will only do the work once.

@gschneider-r7
Copy link
Contributor

There should be a method to list policies as well.

module Nexpose
require 'json'
# Configuration structure for password policies.
class Password_policy < APIObject
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the file name - the name of the class should be PasswordPolicy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rectified this.

@erran-r7
Copy link
Contributor

@adevitt-r7 Stylistic note — we should be consistently using snake_case for variable/method names, CamelCase for class/module names, and SCREAMING_SNAKE_CASE for constants.

attr_accessor :digits
attr_accessor :specialChars

def initialize(policyName:, minLength:, maxLength:, specialChars:, capitals:, digits:)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's refactor all the attrs, and method arguments to use snake_case instead of camelCase

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave #to_h since it is used for the #to_json conversion. We'd want to use the same keys there.

uri = '/api/2.1/password_policy/'
resp = AJAX.get(nsc, uri, AJAX::CONTENT_TYPE::JSON)
hash = JSON.parse(resp, symbolize_names: true)
from_hash(hash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adevitt-r7 this needs to be self.from_hash

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sgreen-r7 @adevitt-r7 Oops, merged before seeing this addressed missing there was still an open comment (the other two open comments are opinions).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adevitt-r7 Fixed by 86b9010 (from @sgreen-r7).

@erran-r7
Copy link
Contributor

@adevitt-r7 awesome, let's :shipit:. When should this get merged down?

@adevitt-r7
Copy link
Contributor Author

@erran-r7 Password policies are going with Odin

erran-r7 added a commit that referenced this pull request May 19, 2015
@erran-r7 erran-r7 merged commit 0aaf068 into master May 19, 2015
@erran-r7 erran-r7 deleted the lamps/password-policy branch May 19, 2015 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants