Skip to content

Commit 548d6ac

Browse files
p-mongop
authored andcommitted
RUBY-2024 Test that auth exceptions include both default and custom auth sources (#1591)
1 parent d350c7e commit 548d6ac

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

spec/integration/auth_spec.rb

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,30 @@
123123
let(:options) { SpecConfig.instance.ssl_options.merge(
124124
user: 'nonexistent_user', password: 'foo') }
125125

126-
it 'reports auth source used' do
127-
expect do
128-
connection.connect!
129-
end.to raise_error(Mongo::Auth::Unauthorized, /User nonexistent_user.*is not authorized to access admin.*auth source: admin/)
130-
end
131-
132126
it 'reports which server authentication was attempted against' do
133127
expect do
134128
connection.connect!
135129
end.to raise_error(Mongo::Auth::Unauthorized, /used server: #{connection.address.to_s}/)
136130
end
131+
132+
context 'with default auth source' do
133+
it 'reports auth source used' do
134+
expect do
135+
connection.connect!
136+
end.to raise_error(Mongo::Auth::Unauthorized, /auth source: admin/)
137+
end
138+
end
139+
140+
context 'with custom auth source' do
141+
let(:options) { SpecConfig.instance.ssl_options.merge(
142+
user: 'nonexistent_user', password: 'foo', auth_source: 'authdb') }
143+
144+
it 'reports auth source used' do
145+
expect do
146+
connection.connect!
147+
end.to raise_error(Mongo::Auth::Unauthorized, /auth source: authdb/)
148+
end
149+
end
137150
end
138151

139152
context 'attempting to connect to a non-tls server with tls' do

0 commit comments

Comments
 (0)