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

Updating validation when creating or editing a provider's endpoint. #10999

Merged
merged 1 commit into from
Sep 14, 2016

Conversation

yaacov
Copy link
Member

@yaacov yaacov commented Sep 4, 2016

Description
A regression was created when introducing multiple provider endpoints to the providers API.
The function for updating authentications did not re-authenticate when changing
an endpoint or an authentication. This commit updates the authentication in this cases.

Issue
#7256

@yaacov
Copy link
Member Author

yaacov commented Sep 4, 2016

@miq-bot add_label providers/containers, api

@simon3z @dkorn @abellotti please review

@@ -107,6 +107,11 @@ def destroy_provider(provider)
end

def update_provider_authentication(provider, data)
connection_configurations = data[CONNECTION_ATTR]
unless connection_configurations.blank?
provider.authentication_check_types_queue(provider.default_authentication, :save => true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Style: @yaacov it is possible to have just a one-liner here. Anyway I am not against what you have here ATM.

Copy link
Member Author

Choose a reason for hiding this comment

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

provider.authentication_check_types_queue(provider.default_authentication, :save => true) unless data[CONNECTION_ATTR].blank?

@simon3z
this line is ok, but rubocop say it's too long :-( any idea ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@simon3z 👍
chenged it to:

endpoints = data[CONNECTION_ATTR]
provider.authentication_check_types_queue(provider.default_authentication, :save => true) unless endpoints.blank?

@simon3z
Copy link
Contributor

simon3z commented Sep 5, 2016

LGTM 👍

@yaacov yaacov force-pushed the api-fix-authentication-on-edit branch from 5f2b908 to 3a1a556 Compare September 5, 2016 08:46
@yaacov
Copy link
Member Author

yaacov commented Sep 6, 2016

@abellotti @imtayadeway please review

@abellotti
Copy link
Member

Can we add a test for this ?
Thanks.

@yaacov yaacov force-pushed the api-fix-authentication-on-edit branch 3 times, most recently from 083b511 to 1a54565 Compare September 7, 2016 12:07
@yaacov
Copy link
Member Author

yaacov commented Sep 7, 2016

@simon3z @abellotti 👍 👍 about the missing tests

While writing the tests I found the real problem.
It was not in the API, but in the ext_management_system model. The model schedule a new authentication refresh when credentials change, but in our case it did it for :default instead of :bearer.

@kbrock please review

@yaacov
Copy link
Member Author

yaacov commented Sep 8, 2016

it's not an API thing now is a core thing :-)

@miq-bot add_label core

@miq-bot remove_label api

cc @abellotti @kbrock

@miq-bot miq-bot added core and removed api labels Sep 8, 2016
@yaacov yaacov changed the title [API] Updating validation when creating or editing a provider's endpoint. Updating validation when creating or editing a provider's endpoint. Sep 8, 2016
@simon3z
Copy link
Contributor

simon3z commented Sep 8, 2016

👍 cc @chessbyte ready for merge

@abellotti
Copy link
Member

I'm 👍 with this.

@imtayadeway
Copy link
Contributor

The fix looks good.....I'm just wondering if a) The problem was in the model, and b) The tests aren't concerned with the response from the API, that a model spec would be more appropriate?

@kbrock
Copy link
Member

kbrock commented Sep 9, 2016

To follow up on @imtayadeway there are [examples] in the tests for testing that method.

Also, if you are testing a particular method, please use a describe at the top level with your method under test. The example I provided you does not do that, so you'd need to add a block for testing connection_configuration_by_role

e.g.:

describe VmOrTemplate do
  describe "#connection_configuration_by_role" do
    # context if you need
    it "works with no parameters" do
      # ...
    end
  end
end

@yaacov yaacov force-pushed the api-fix-authentication-on-edit branch 2 times, most recently from d6a1a03 to 74a00da Compare September 9, 2016 14:22
A regression was created when introducing multiple provider endpoints.
The function for updating authentications was not updated to update when changing
the endpoints and authentications.
This commit updates the authentication is this cases.

Issue:
ManageIQ#7256
@yaacov yaacov force-pushed the api-fix-authentication-on-edit branch from 74a00da to 7840799 Compare September 9, 2016 14:34
@yaacov
Copy link
Member Author

yaacov commented Sep 9, 2016

@kbrock @implowry Thanks 👍

  1. Added a spec to test how connection_configuration_by_role behaves when role is missing.
  2. Did not remove the tests on the api because the bug/issue was reported on the API [1].

[1] To make this bug happen you need to call the function with missing authentication role. Currently this is the case only in the api's edit action (authentication objects do not have role fields), so the bug of wrongly guessing what is the authentication authtype based on the endpoint role is linked to the api.

@kbrock I used context, because all the tests around do so, I do not know if to describe here ?

@miq-bot
Copy link
Member

miq-bot commented Sep 9, 2016

Checked commit yaacov@7840799 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
3 files checked, 0 offenses detected
Everything looks good. ⭐

@imtayadeway
Copy link
Contributor

imtayadeway commented Sep 9, 2016

Did not remove the tests on the api because the bug/issue was reported on the API [1].

@yaacov that's fine - I just generally prefer to test only things in the response in request specs, and leave the nitty-gritty things up to lower level tests if their behavior never bubbles up to the user in the response

@yaacov
Copy link
Member Author

yaacov commented Sep 13, 2016

@kbrock please re-review

@kbrock
Copy link
Member

kbrock commented Sep 14, 2016

👍 LGTM - Mr. @abellotti you have the floor

@abellotti abellotti added this to the Sprint 47 Ending Oct 3, 2016 milestone Sep 14, 2016
@abellotti
Copy link
Member

Thanks @kbrock

@abellotti abellotti merged commit 091627b into ManageIQ:master Sep 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants