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

Add a verify_credentials_task method #19346

Merged
merged 1 commit into from
Oct 1, 2019

Conversation

agrare
Copy link
Member

@agrare agrare commented Sep 30, 2019

This adds a method that takes the options returned by
ems.params_for_create and calls a common verify_credentials API call on
the provider.

This can be called by the API/UI without needing to know anything about
the specific provider in a common way.

TODO need to update the task with the failure and ensure a boolean is returned so we don't leak the credentials on the queue.

#18818

@agrare agrare changed the title Add a verify_credentials_task method [WIP] Add a verify_credentials_task method Sep 30, 2019
@miq-bot miq-bot added the wip label Sep 30, 2019
@agrare agrare force-pushed the add_a_verify_credentials_task branch 2 times, most recently from 954c24c to 039697b Compare September 30, 2019 19:33
This adds a method that takes the options returned by
ems.params_for_create and calls a common verify_credentials API call on
the provider.

This can be called by the API/UI without needing to know anything about
the specific provider in a common way.
@agrare agrare force-pushed the add_a_verify_credentials_task branch from 039697b to 27daabf Compare September 30, 2019 19:35
@agrare agrare removed the wip label Sep 30, 2019
@agrare agrare changed the title [WIP] Add a verify_credentials_task method Add a verify_credentials_task method Sep 30, 2019
@miq-bot
Copy link
Member

miq-bot commented Sep 30, 2019

Checked commit agrare@27daabf with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
3 files checked, 1 offense detected

app/models/mixins/verify_credentials_mixin.rb

Copy link
Member

@Fryguy Fryguy left a comment

Choose a reason for hiding this comment

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

👍 I'm only holding off merging cause you said you wanted to manually test a few things. Let me know how that goes and than I can merge.

@agrare
Copy link
Member Author

agrare commented Sep 30, 2019

Oh I tested it with you @Fryguy I just wanted to make sure after we renamed the module that everything still worked.

@skateman
Copy link
Member

skateman commented Oct 1, 2019

@agrare I'm playing around with the method in the API, but I have no idea what to feed the zone argument with. My first idea was to retrieve it from the form itself, but at least for the oVirt schema there's no such thing.

@Fryguy Fryguy merged commit 40d9028 into ManageIQ:master Oct 1, 2019
@Fryguy Fryguy added this to the Sprint 122 Ending Oct 14, 2019 milestone Oct 1, 2019
@Fryguy
Copy link
Member

Fryguy commented Oct 1, 2019

@agrare Oh I thought you were talking about the move of validate_credentials and ensuring that still works. (Spoke with @agrare offline and he said this was all tested as well and works).

@agrare agrare deleted the add_a_verify_credentials_task branch October 1, 2019 18:56
@Fryguy
Copy link
Member

Fryguy commented Oct 1, 2019

@skateman Do we not have zone as part of the form? I'm thinking that every EMS needs a zone, and it doesn't really belong to the DDF form as it's more of a general ManageIQ thing as opposed to a provider specific thing.

@skateman
Copy link
Member

skateman commented Oct 1, 2019

Well, I think we should ask @Hyperkid123 about it, but injecting data into the DDF seems like an antipattern for me...and we don't have any other way of displaying the Zone field than injecting data into the DDF 😕

@agrare
Copy link
Member Author

agrare commented Oct 2, 2019

We could add zone to the DDF form at the top level (like region for amazon) but it can't be passed in to verify_credentials_task like the rest of the args because it has to be part of the queue_options not the args. This isn't something that is different between the different providers though, it is the same for every provider.

@skateman
Copy link
Member

skateman commented Oct 2, 2019

@agrare I'm okay with explicitly pulling out the zone for the verification, especially if the field is the same in every form.

    def verify_credentials_resource(_type, _id, options = {})
      zone = options.delete('zone')
      ExtManagementSystem.verify_credentials_task(current_user, zone, options)
    end

This should be done even when we add the zone field to the DDF as you wanted first. So I'm totally okay with it.

@Hyperkid123
Copy link

@agrare From UI perspective. there is minimum of two sections for every provider form:

  • general info (top level)
  • credentials info.
    In UI zone is always in the "general" part of form. So it should be part of the top level of the schema IMO.

@skateman I do agree that injecting data into the schema is not exactly the cleanest way how to it, but I also believe that in this case we probably don't have any other options.

@skateman
Copy link
Member

skateman commented Oct 2, 2019

Okay, if you can guarantee me that the zone will be sent with the form, I can work with that. Just let's agree on the format, so I can adjust my method from above.

# Ensure that any passwords are encrypted before putting them onto the queue for any
# DDF fields which are a password type
def encrypt_verify_credential_params!(options)
params_for_create[:fields].each do |field|
Copy link
Member

Choose a reason for hiding this comment

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

This is failing with an undefined method if called from ExtManagementSystem. My guess is that it's only applicable when an already existing provider is being verified, which is not very useful in our case. @Fryguy @agrare

Copy link
Member Author

Choose a reason for hiding this comment

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

@skateman this is expected to be called on the provider class not on the base class.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, this can be sorted out.

[error_message.blank?, error_message]
end

def verify_credentials_task(userid, zone, options)
Copy link
Member

@skateman skateman Oct 2, 2019

Choose a reason for hiding this comment

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

The zone argument here should be the name of the zone, right? I think it's not obvious, at least I was debugging this for half an hour 😕

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, sorry if its not obvious but that's the standard for all tasks and queue items.

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.

5 participants