File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 521
521
end
522
522
end
523
523
524
- context 'when the user is not authorized' do
524
+ context 'when the user is not authorized' , if : auth_enabled? do
525
525
526
526
let ( :view ) do
527
527
unauthorized_collection . find
Original file line number Diff line number Diff line change 180
180
end
181
181
end
182
182
183
- context 'when the user is not authorized' , unless : sharded ? do
183
+ context 'when the user is not authorized' , if : auth_enabled ? do
184
184
185
185
let ( :database ) do
186
186
described_class . new ( unauthorized_client , TEST_DB )
Original file line number Diff line number Diff line change 20
20
Mongo ::Logger . logger = Logger . new ( $stdout)
21
21
Mongo ::Logger . logger . level = Logger ::INFO
22
22
23
+ require 'pry'
23
24
require 'support/travis'
24
25
require 'support/matchers'
25
26
require 'support/authorization'
@@ -171,6 +172,15 @@ def failing_delete_doc
171
172
{ que : { field : 'test' } }
172
173
end
173
174
175
+ # Try running a command on the admin database to see if the mongod was started with auth.
176
+ #
177
+ # @since 2.2.0
178
+ def auth_enabled?
179
+ $mongo_client ||= initialize_scanned_client!
180
+ begin ; $mongo_client. use ( :admin ) . command ( getCmdLineOpts : 1 ) ; rescue ; return true ; end
181
+ false
182
+ end
183
+
174
184
# Initializes a basic scanned client to do an ismaster check.
175
185
#
176
186
# @since 2.0.0
You can’t perform that action at this time.
0 commit comments