Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Cheal committed Nov 6, 2018
1 parent adb680d commit e8377ba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions db/fixtures/miq_event_definitions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ name,description,event_type,set_type
#
login_failed,Login failed,Default,authentication

# Authorization
user_created,User created,Default,authorization

#
# EVM Server operations
#
Expand Down
1 change: 1 addition & 0 deletions spec/models/authenticator/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def authenticate
expect(AuditEvent).not_to receive(:failure)
authenticate
end

it "updates lastlogon" do
expect(-> { authenticate }).to change { alice.reload.lastlogon }
end
Expand Down
15 changes: 15 additions & 0 deletions spec/models/authenticator/ldap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,21 @@ def authenticate
expect(User.find_by_userid(task.userid)).to eq(alice)
end

context "new user creation" do
let(:username) { 'bob' }
it "logs the success" do
authenticate
expect(MiqQueue.count).to eq 1
expect(MiqQueue.first.args.last(2)).to eq(
["user_created",
{
:event_details => "User creation successful for User: Bob Builderson with ID: bob"
}
]
)
end
end

context "with no corresponding LDAP user" do
let(:alice_data) { nil }
it "fails" do
Expand Down

0 comments on commit e8377ba

Please sign in to comment.