MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / test_gssapi_simple

Method test_gssapi_simple

test/test_auth.py:126–212  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

124
125 @ignore_deprecations
126 def test_gssapi_simple(self):
127 assert GSSAPI_PRINCIPAL is not None
128 if GSSAPI_PASS is not None:
129 uri = "mongodb://%s:%s@%s:%d/?authMechanism=GSSAPI" % (
130 quote_plus(GSSAPI_PRINCIPAL),
131 GSSAPI_PASS,
132 GSSAPI_HOST,
133 GSSAPI_PORT,
134 )
135 else:
136 uri = "mongodb://%s@%s:%d/?authMechanism=GSSAPI" % (
137 quote_plus(GSSAPI_PRINCIPAL),
138 GSSAPI_HOST,
139 GSSAPI_PORT,
140 )
141
142 if not self.service_realm_required:
143 # Without authMechanismProperties.
144 client = self.simple_client(
145 GSSAPI_HOST,
146 GSSAPI_PORT,
147 username=GSSAPI_PRINCIPAL,
148 password=GSSAPI_PASS,
149 authMechanism="GSSAPI",
150 )
151
152 client[GSSAPI_DB].collection.find_one()
153
154 # Log in using URI, without authMechanismProperties.
155 client = self.simple_client(uri)
156 client[GSSAPI_DB].collection.find_one()
157
158 # Authenticate with authMechanismProperties.
159 client = self.simple_client(
160 GSSAPI_HOST,
161 GSSAPI_PORT,
162 username=GSSAPI_PRINCIPAL,
163 password=GSSAPI_PASS,
164 authMechanism="GSSAPI",
165 authMechanismProperties=self.mech_properties,
166 )
167
168 client[GSSAPI_DB].collection.find_one()
169
170 # Log in using URI, with authMechanismProperties.
171 mech_properties_str = ""
172 for key, value in self.mech_properties.items():
173 mech_properties_str += f"{key}:{value},"
174 mech_uri = uri + f"&authMechanismProperties={mech_properties_str[:-1]}"
175 client = self.simple_client(mech_uri)
176 client[GSSAPI_DB].collection.find_one()
177
178 set_name = client_context.replica_set_name
179 if set_name:
180 if not self.service_realm_required:
181 # Without authMechanismProperties
182 client = self.simple_client(
183 GSSAPI_HOST,

Callers

nothing calls this directly

Calls 4

itemsMethod · 0.80
simple_clientMethod · 0.45
find_oneMethod · 0.45
list_collection_namesMethod · 0.45

Tested by

no test coverage detected