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

Disable Look up Group for Amazon, Database and External with SAML #3881

Merged
merged 2 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/views/ops/_rbac_group_details.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
- if @edit
- url = url_for_only_path(:action => 'rbac_group_field_changed', :id => (@edit[:group_id] || "new"))
- combo_url = "/ops/rbac_group_field_changed/#{@edit[:group_id] || 'new'}"
- mode = ::Settings.authentication.mode
- saml_enabled = ::Settings.authentication.saml_enabled
- can_lookup_groups = mode.downcase.start_with?('ldap')
- can_lookup_groups = mode.downcase == "httpd" && ! saml_enabled unless can_lookup_groups
= render :partial => "layouts/flash_msg"
#group_info
%h3
Expand All @@ -21,7 +25,7 @@
:class => "form-control",
"data-miq_observe" => {:interval => '.5',
:url => url}.to_json)
- if ::Settings.authentication.mode.casecmp('database') != 0
- if can_lookup_groups
= check_box_tag("lookup",
"1",
false,
Expand Down
15 changes: 11 additions & 4 deletions spec/views/ops/_rbac_group_details.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,27 @@
expect(rendered).to include('Look up LDAPS Groups')
end

it 'should show "Look up groups" checkbox and label for auth mode amazon' do
it 'should not show "Look up groups" checkbox and label for auth mode amazon' do
stub_settings(:authentication => { :mode => 'amazon' }, :server => {})
render :partial => 'ops/rbac_group_details'
expect(rendered).to have_selector('input#lookup')
expect(rendered).to include('Look up Amazon Groups')
expect(rendered).not_to have_selector('input#lookup')
expect(rendered).not_to include('Look up Amazon Groups')
end

it 'should show "Look up groups" checkbox and label for auth mode httpd' do
stub_settings(:authentication => { :mode => 'httpd' }, :server => {})
stub_settings(:authentication => { :mode => 'httpd', :saml_enabled => false}, :server => {})
render :partial => 'ops/rbac_group_details'
expect(rendered).to have_selector('input#lookup')
expect(rendered).to include('Look up External Authentication Groups')
end

it 'should not show "Look up groups" checkbox and label for auth mode httpd with SAML enabled' do
stub_settings(:authentication => { :mode => 'httpd', :saml_enabled => true}, :server => {})
render :partial => 'ops/rbac_group_details'
expect(rendered).not_to have_selector('input#lookup')
expect(rendered).not_to include('Look up External Authentication Groups')
end

it 'should not show "Look up groups" checkbox and label for auth mode database' do
stub_settings(:authentication => { :mode => 'database' }, :server => {})
render :partial => 'ops/rbac_group_details'
Expand Down