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 521521 end
522522 end
523523
524- context 'when the user is not authorized' do
524+ context 'when the user is not authorized' , if : auth_enabled? do
525525
526526 let ( :view ) do
527527 unauthorized_collection . find
Original file line number Diff line number Diff line change 180180 end
181181 end
182182
183- context 'when the user is not authorized' , unless : sharded ? do
183+ context 'when the user is not authorized' , if : auth_enabled ? do
184184
185185 let ( :database ) do
186186 described_class . new ( unauthorized_client , TEST_DB )
Original file line number Diff line number Diff line change 2020Mongo ::Logger . logger = Logger . new ( $stdout)
2121Mongo ::Logger . logger . level = Logger ::INFO
2222
23+ require 'pry'
2324require 'support/travis'
2425require 'support/matchers'
2526require 'support/authorization'
@@ -171,6 +172,15 @@ def failing_delete_doc
171172 { que : { field : 'test' } }
172173end
173174
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+
174184# Initializes a basic scanned client to do an ismaster check.
175185#
176186# @since 2.0.0
You can’t perform that action at this time.
0 commit comments