Skip to content

Commit

Permalink
Merge pull request #9298 from Fryguy/add_external_auth_spec
Browse files Browse the repository at this point in the history
Add external auth spec
  • Loading branch information
jrafanie authored Oct 24, 2024
2 parents 61578ea + 7fc10a8 commit abfd3d2
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions spec/controllers/dashboard_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,54 @@
end
end

context "external auth support" do
let(:user) { FactoryBot.create(:user, :role => "random") }
let(:user_name) { user.userid }
let(:user_domain) { "ipa.example.org" }
let(:user_email) { "#{user_name}@#{user_domain}" }
let(:user_group) { user.miq_groups.first.description }

before do
EvmSpecHelper.create_guid_miq_server_zone

stub_settings_merge(:authentication => {:mode => 'httpd', :httpd_role => true})
request.headers.merge!(
"HTTP_X_REMOTE_USER" => user_name,
"HTTP_X_REMOTE_USER_EMAIL" => user_email,
"HTTP_X_REMOTE_USER_DOMAIN" => user_domain,
"HTTP_X_REMOTE_USER_GROUPS" => user_group
)
end

it "initiates a task when logging in" do
skip_data_checks
post :external_authenticate, :params => {:user_name => user_name, :user_password => 'dummy'}
expect_failed_login # Not really failed, but waiting to complete

task = MiqTask.first
expect(task).to have_attributes(
:name => "External httpd User Authorization of '#{user_name}'",
:message => "User authorized successfully",
:state => "Finished",
:status => "Ok",
:userid => user_email
)

post :wait_for_task, :params => {:task_id => task.id}
expect_successful_login(user)
end

it "serializes the session properly between the task initiation and waiting for the task" do
skip_data_checks
post :external_authenticate, :params => {:user_name => user_name, :user_password => 'dummy'}

# In Rails test environment, we use memory session storage, but in production
# we use memcached. memcached Marshal.dump's the session, so we do that here
# manually to ensure it doesn't blow up.
Marshal.load(Marshal.dump(session))
end
end

context "SAML and OIDC support" do
before { EvmSpecHelper.create_guid_miq_server_zone }

Expand Down

0 comments on commit abfd3d2

Please sign in to comment.