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

Deleting Test connection button and changing Api Keys in UI to Access Keys #2

Merged
merged 3 commits into from
May 24, 2016

Conversation

moizjv
Copy link

@moizjv moizjv commented May 23, 2016

ECO-1169

@halkeye please review

<f:textbox/>
</f:entry>
<f:validateButton title="${%Test Connection}" with="username,apiKey" method="validate"/>
Copy link

Choose a reason for hiding this comment

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

now that the button is gone, can you delete the associated function as well?
(I think its called doValidate)

Copy link
Author

Choose a reason for hiding this comment

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

yeah good point

Copy link
Author

@moizjv moizjv May 23, 2016

Choose a reason for hiding this comment

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

I still think it is used for automatic validation

Copy link
Author

Choose a reason for hiding this comment

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

you are awesome @halkeye! removed some code

@halkeye
Copy link

halkeye commented May 23, 2016

I think doCheckApiKey is used for checking if it works, I think doValidate is no longer used because the button is removed. You should be able to check really easily though.

public FormValidation doValidate(@QueryParameter String username, @QueryParameter String apiKey) {
if (actualValidate(username, apiKey))
SauceREST rest = new JenkinsSauceREST(username, value);
if (!rest.getUser().equals("")) {
Copy link

Choose a reason for hiding this comment

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

Personal style here, I find that ! equals("") confusing to read.

I think with java 7, its safe to compare strings using operators, so do you want to try rest.getUser() != "" which might be clearer. Otherwise do you want to make it its own simple function called "isValidCredentials" or something so the conditional is easier to read?

Copy link
Author

Choose a reason for hiding this comment

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

I agree, i was thinking to refactor some more to actually check 401 unauthorized, as that would be the actual correct way to deal with this.

@halkeye
Copy link

halkeye commented May 24, 2016

Thats actually one of the ugly features in saucerest. Any error returns a blank string. saucerest isn't likely to be fixed any time soon.

@moizjv
Copy link
Author

moizjv commented May 24, 2016

Made it the other way so it is more readable and also added a comment

@halkeye
Copy link

halkeye commented May 24, 2016

I think in this case its fine because sauceRest is crazy, but generally comments about statements are considered a code smell so its something to watch out for.

https://sourcemaking.com/refactoring/smells/comments

@moizjv
Copy link
Author

moizjv commented May 24, 2016

I totally agree 👍

@halkeye
Copy link

halkeye commented May 24, 2016

yea, looks like everything passes, so assuming everyone else is cool, :shipit:

@moizjv moizjv merged commit c2690c8 into master May 24, 2016
@halkeye halkeye deleted the access-key-label branch May 26, 2016 18:38
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.

2 participants