Skip to content

Commit

Permalink
Unable to change product authentication method (#3029)
Browse files Browse the repository at this point in the history
Fix integration > settings: unable to change product authentication method
  • Loading branch information
lvillen authored and akostadinov committed Aug 8, 2022
1 parent 7e80ae6 commit 1c41716
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
3 changes: 1 addition & 2 deletions app/views/api/services/forms/_integration_settings.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

= form.inputs 'Authentication', id: 'auth-wrapper' do
= form.input :proxy_authentication_method,
name: 'service[backend_version]',
as: :radio,
required: false,
collection: BackendVersion.visible_versions(service: service),
value_as_class: true,
label: false,
input_html: {class: 'auth-method'}
input_html: { class: 'auth-method', name: 'service[backend_version]' }

= form.semantic_fields_for :proxy do |f|
= render 'api/services/forms/authentication_settings', f: f, oauth_hint: 'apicast_oauth'
33 changes: 33 additions & 0 deletions test/integration/api/services_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,39 @@ class SettingsTest < self
assert hosted_option.attribute('checked').present?
end

test 'shows and update authentication options' do
# Default value
get settings_admin_service_path(service)

page = Nokogiri::HTML::Document.parse(response.body)
default = page.at_css('#service_proxy_authentication_method_1')
assert default.attribute('checked').present?

# App_Id and App_Key Pair
put admin_service_path(service), params: update_params.deep_merge(service: { backend_version: '2' })

assert_equal 'Product information updated.', flash[:notice]

get settings_admin_service_path(service)

page = Nokogiri::HTML::Document.parse(response.body)
app_id_app_key_option = page.at_css('#service_proxy_authentication_method_2')

assert app_id_app_key_option.attribute('checked').present?

# API Key (user_key)
put admin_service_path(service), params: update_params.deep_merge(service: { backend_version: '1' })

assert_equal 'Product information updated.', flash[:notice]

get settings_admin_service_path(service)

page = Nokogiri::HTML::Document.parse(response.body)
api_key_option = page.at_css('#service_proxy_authentication_method_1')

assert api_key_option.attribute('checked').present?
end

test 'update the settings' do
Account.any_instance.stubs(:provider_can_use?).returns(true)
service.update!(deployment_option: 'self_managed')
Expand Down

0 comments on commit 1c41716

Please sign in to comment.