Skip to content

Commit f01d2c5

Browse files
committed
Normalize 'mech' argument name
All instances of the 'mech_type' and 'mech_types' arguments have been converted into the 'mech' and 'mechs' arguments, respectively. Additionally, the relevant properties of the named tuples have been updated as well.
1 parent b1ecdab commit f01d2c5

File tree

8 files changed

+47
-47
lines changed

8 files changed

+47
-47
lines changed

gssapi/names.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,20 @@ def export(self):
9999

100100
return rname.export_name(self)
101101

102-
def canonicalize(self, mech_type):
102+
def canonicalize(self, mech):
103103
"""Canonicalize a name with respect to a mechanism
104104
105105
This method returns a new Name that is canonicalized according to
106106
the given mechanism.
107107
108108
Args:
109-
mech_type (OID): the mechanism type to use
109+
mech (OID): the mechanism type to use
110110
111111
Returns:
112112
Name: the canonicalized name
113113
"""
114114

115-
return type(self)(rname.canonicalize_name(self, mech_type))
115+
return type(self)(rname.canonicalize_name(self, mech))
116116

117117
def __copy__(self):
118118
return type(self)(rname.duplicate_name(self))

gssapi/raw/misc.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ def indicate_mechs():
5252
raise GSSError(maj_stat, min_stat)
5353

5454

55-
def inquire_names_for_mech(OID mech_type not None):
55+
def inquire_names_for_mech(OID mech not None):
5656
"""Get the name types supported by a mechanism.
5757
5858
This method retrives the different name types supported by
5959
the given mechanism.
6060
6161
Args:
62-
mech_type (OID): the mechanism in question
62+
mech (OID): the mechanism in question
6363
6464
Returns:
6565
list: the name type OIDs supported by the given mechanism
@@ -72,7 +72,7 @@ def inquire_names_for_mech(OID mech_type not None):
7272

7373
cdef OM_uint32 maj_stat, min_stat
7474

75-
maj_stat = gss_inquire_names_for_mech(&min_stat, &mech_type.raw_oid,
75+
maj_stat = gss_inquire_names_for_mech(&min_stat, &mech.raw_oid,
7676
&name_types)
7777

7878
if maj_stat == GSS_S_COMPLETE:
@@ -111,7 +111,7 @@ def inquire_mechs_for_name(Name name not None):
111111

112112

113113
def _display_status(unsigned int error_code, bint is_major_code,
114-
OID mech_type=None, unsigned int message_context=0):
114+
OID mech=None, unsigned int message_context=0):
115115
"""
116116
Display a string message for a GSSAPI error code.
117117
@@ -126,7 +126,7 @@ def _display_status(unsigned int error_code, bint is_major_code,
126126
error_code (int): The error code in question
127127
is_major_code (bool): is this a major code (True) or a
128128
minor code (False)
129-
mech_type (MechType): The mechanism type that returned this error code
129+
mech (MechType): The mechanism type that returned this error code
130130
(defaults to None, for the default mechanism)
131131
message_context (int): The context for this call -- this is used when
132132
multiple messages are available (defaults to 0)
@@ -147,10 +147,10 @@ def _display_status(unsigned int error_code, bint is_major_code,
147147
else:
148148
status_type = GSS_C_MECH_CODE
149149

150-
if mech_type is None:
150+
if mech is None:
151151
c_mech_type = GSS_C_NO_OID
152152
else:
153-
c_mech_type = &mech_type.raw_oid
153+
c_mech_type = &mech.raw_oid
154154

155155
cdef OM_uint32 maj_stat
156156
cdef OM_uint32 min_stat

gssapi/raw/named_tuples.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@
3939

4040
AcceptSecContextResult = namedtuple('AcceptSecContextResult',
4141
['context', 'initiator_name',
42-
'mech_type', 'token', 'flags', 'lifetime',
42+
'mech', 'token', 'flags', 'lifetime',
4343
'delegated_creds', 'more_steps'])
4444

4545

4646
InitSecContextResult = namedtuple('InitSecContextResult',
47-
['context', 'mech_type', 'flags', 'token',
47+
['context', 'mech', 'flags', 'token',
4848
'lifetime', 'more_steps'])
4949

5050

5151
InquireContextResult = namedtuple('InquireContextResult',
5252
['initiator_name', 'target_name',
53-
'lifetime', 'mech_type', 'flags',
53+
'lifetime', 'mech', 'flags',
5454
'locally_init', 'complete'])
5555

5656
StoreCredResult = namedtuple('StoreCredResult',
57-
['mech_types', 'usage'])
57+
['mechs', 'usage'])

gssapi/raw/names.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def export_name(Name name not None):
240240
raise GSSError(maj_stat, min_stat)
241241

242242

243-
def canonicalize_name(Name name not None, OID mech_type not None):
243+
def canonicalize_name(Name name not None, OID mech not None):
244244
"""
245245
Canonicalize an arbitrary GSSAPI Name into a Mechanism Name
246246
@@ -250,7 +250,7 @@ def canonicalize_name(Name name not None, OID mech_type not None):
250250
251251
Args:
252252
name (Name): the name to canonicalize
253-
mech_type (MechType): the mechanism type to use to
253+
mech (MechType): the mechanism type to use to
254254
canonicalize the name
255255
256256
Returns:
@@ -266,7 +266,7 @@ def canonicalize_name(Name name not None, OID mech_type not None):
266266

267267
with nogil:
268268
maj_stat = gss_canonicalize_name(&min_stat, name.raw_name,
269-
&mech_type.raw_oid,
269+
&mech.raw_oid,
270270
&canonicalized_name)
271271

272272
cdef Name cn = Name()

gssapi/raw/sec_contexts.pyx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ cdef class SecurityContext:
111111
# TODO(directxman12): figure out whether GSS_C_NO_NAME can be passed in here
112112
def init_sec_context(Name target_name not None, Creds cred=None,
113113
SecurityContext context=None,
114-
OID mech_type=None,
114+
OID mech=None,
115115
flags=None, lifetime=None,
116116
ChannelBindings channel_bindings=None,
117117
input_token=None):
@@ -132,7 +132,7 @@ def init_sec_context(Name target_name not None, Creds cred=None,
132132
or None to use the default credentials
133133
context (SecurityContext): the security context to update, or
134134
None to create a new context
135-
mech_type (MechType): the mechanism type for this security context,
135+
mech (MechType): the mechanism type for this security context,
136136
or None for the default mechanism type
137137
flags ([RequirementFlag]): the flags to request for the security
138138
context, or None to use the default set: mutual_authentication and
@@ -156,8 +156,8 @@ def init_sec_context(Name target_name not None, Creds cred=None,
156156
"""
157157

158158
cdef gss_OID mech_oid
159-
if mech_type is not None:
160-
mech_oid = &mech_type.raw_oid
159+
if mech is not None:
160+
mech_oid = &mech.raw_oid
161161
else:
162162
mech_oid = GSS_C_NO_OID
163163

@@ -343,13 +343,13 @@ def accept_sec_context(input_token not None, Creds acceptor_cred=None,
343343

344344

345345
def inquire_context(SecurityContext context not None, initiator_name=True,
346-
target_name=True, lifetime=True, mech_type=True,
346+
target_name=True, lifetime=True, mech=True,
347347
flags=True, locally_init=True, complete=True):
348348
"""
349349
Get information about a security context.
350350
351351
This method obtains information about a security context, including
352-
the initiator and target names, as well as the TTL, mech type,
352+
the initiator and target names, as well as the TTL, mech,
353353
flags, and its current state (open vs closed).
354354
355355
Note: the target name may be None if it would have been GSS_C_NO_NAME
@@ -384,7 +384,7 @@ def inquire_context(SecurityContext context not None, initiator_name=True,
384384

385385
cdef gss_OID output_mech_type
386386
cdef gss_OID *mech_type_ptr = NULL
387-
if mech_type:
387+
if mech:
388388
mech_type_ptr = &output_mech_type
389389

390390
cdef OM_uint32 output_flags
@@ -425,7 +425,7 @@ def inquire_context(SecurityContext context not None, initiator_name=True,
425425
else:
426426
tn = None
427427

428-
if mech_type:
428+
if mech:
429429
py_mech_type = OID()
430430
py_mech_type.raw_oid = output_mech_type[0]
431431
else:

gssapi/sec_contexts.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SecurityContext(rsec_contexts.SecurityContext):
2727

2828
def __new__(cls, base=None, token=None,
2929
name=None, creds=None, lifetime=None, flags=None,
30-
mech_type=None, channel_bindings=None, usage=None):
30+
mech=None, channel_bindings=None, usage=None):
3131

3232
if token is not None:
3333
base = rsec_contexts.import_sec_context(token)
@@ -36,7 +36,7 @@ def __new__(cls, base=None, token=None,
3636

3737
def __init__(self, base=None, token=None,
3838
name=None, creds=None, lifetime=None, flags=None,
39-
mech_type=None, channel_bindings=None, usage=None):
39+
mech=None, channel_bindings=None, usage=None):
4040
"""
4141
The constructor creates a new security context, but does not begin
4242
the initiate or accept process.
@@ -55,7 +55,7 @@ def __init__(self, base=None, token=None,
5555
security context (if `base` or `token` are used) or the argument set.
5656
5757
For a security context of the `initiate` usage, the `name` argument
58-
must be used, and the `creds`, `mech_type`, `flags`,
58+
must be used, and the `creds`, `mech`, `flags`,
5959
`lifetime`, and `channel_bindings` arguments may be
6060
used as well.
6161
@@ -86,19 +86,19 @@ def __init__(self, base=None, token=None,
8686

8787
# check for appropriate arguments
8888
if self.usage == 'initiate':
89-
# takes: creds?, target_name, mech_type?, flags?,
89+
# takes: creds?, target_name, mech?, flags?,
9090
# channel_bindings?
9191
if name is None:
9292
raise TypeError("You must pass the 'name' argument when "
9393
"creating an initiating security context")
9494
self._target_name = name
95-
self._mech_type = mech_type
95+
self._mech = mech
9696
self._desired_flags = IntEnumFlagSet(RequirementFlag, flags)
9797
self._desired_lifetime = lifetime
9898
else:
9999
# takes creds?
100100
if (name is not None or flags is not None or
101-
mech_type is not None or lifetime is not None):
101+
mech is not None or lifetime is not None):
102102
raise TypeError("You must pass at most the 'creds' "
103103
"argument when creating an accepting "
104104
"security context")
@@ -290,7 +290,7 @@ def export(self):
290290
return rsec_contexts.export_sec_context(self)
291291

292292
_INQUIRE_ARGS = ('initiator_name', 'target_name', 'lifetime',
293-
'mech_type', 'flags', 'locally_init', 'complete')
293+
'mech', 'flags', 'locally_init', 'complete')
294294

295295
@_utils.check_last_err
296296
def _inquire(self, **kwargs):
@@ -306,7 +306,7 @@ def _inquire(self, **kwargs):
306306
initiator_name (bool): get the initiator name for this context
307307
target_name (bool): get the target name for this context
308308
lifetime (bool): get the remaining lifetime for this context
309-
mech_type (bool): get the mechanism used by this context
309+
mech (bool): get the mechanism used by this context
310310
flags (bool): get the flags set on this context
311311
locally_init (bool): get whether this context was locally initiated
312312
complete (bool): get whether negotiation on this context has
@@ -339,7 +339,7 @@ def _inquire(self, **kwargs):
339339
target_name = None
340340

341341
return tuples.InquireContextResult(init_name, target_name,
342-
res.lifetime, res.mech_type,
342+
res.lifetime, res.mech,
343343
res.flags, res.locally_init,
344344
res.complete)
345345

@@ -352,8 +352,8 @@ def lifetime(self):
352352
'initiator_name', 'Get the Name of the initiator of this context')
353353
target_name = _utils.inquire_property(
354354
'target_name', 'Get the Name of the target of this context')
355-
mech_type = _utils.inquire_property(
356-
'mech_type', 'Get the mechanism in use by this context')
355+
mech = _utils.inquire_property(
356+
'mech', 'Get the mechanism in use by this context')
357357
actual_flags = _utils.inquire_property(
358358
'flags', 'Get the flags set on this context')
359359
locally_initiated = _utils.inquire_property(
@@ -412,7 +412,7 @@ def _acceptor_step(self, token):
412412

413413
def _initiator_step(self, token=None):
414414
res = rsec_contexts.init_sec_context(self._target_name, self._creds,
415-
self, self._mech_type,
415+
self, self._mech,
416416
self._desired_flags,
417417
self._desired_lifetime,
418418
self._channel_bindings,

gssapi/tests/test_high_level.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def test_store_acquire(self):
175175

176176
store_res = deleg_creds.store(usage='initiate', set_default=True)
177177
store_res.usage.should_be('initiate')
178-
store_res.mech_types.should_include(gb.MechType.kerberos)
178+
store_res.mechs.should_include(gb.MechType.kerberos)
179179

180180
reacquired_creds = gsscreds.Credentials(name=deleg_creds.name,
181181
usage='initiate')
@@ -197,8 +197,8 @@ def test_store_into_acquire_from(self):
197197

198198
store_res = initial_creds.store(store, overwrite=True)
199199

200-
store_res.mech_types.shouldnt_be_none()
201-
store_res.mech_types.shouldnt_be_empty()
200+
store_res.mechs.shouldnt_be_none()
201+
store_res.mechs.shouldnt_be_empty()
202202
store_res.usage.should_be('initiate')
203203

204204
name = gssnames.Name(princ_name)
@@ -288,8 +288,8 @@ def test_store_into_add_from(self):
288288

289289
store_res = initial_creds.store(store, overwrite=True)
290290

291-
store_res.mech_types.shouldnt_be_none()
292-
store_res.mech_types.shouldnt_be_empty()
291+
store_res.mechs.shouldnt_be_none()
292+
store_res.mechs.shouldnt_be_empty()
293293
store_res.usage.should_be('initiate')
294294

295295
name = gssnames.Name(princ_name)
@@ -484,7 +484,7 @@ def test_create_from_other(self):
484484
high_level_ctx.target_name.should_be(self.target_name)
485485

486486
@exist_perms(lifetime=30, flags=[],
487-
mech_type=gb.MechType.kerberos,
487+
mech=gb.MechType.kerberos,
488488
channel_bindings=None)
489489
def test_create_new_init(self, str_name, kwargs):
490490
client_ctx = gssctx.SecurityContext(name=self.target_name,
@@ -524,14 +524,14 @@ def test_initiate_accept_steps(self):
524524

525525
server_ctx.lifetime.should_be_at_most(400)
526526
server_ctx.initiator_name.should_be(client_ctx.initiator_name)
527-
server_ctx.mech_type.should_be_a(gb.OID)
527+
server_ctx.mech.should_be_a(gb.OID)
528528
server_ctx.actual_flags.should_be_a(gb.IntEnumFlagSet)
529529
server_ctx.locally_initiated.should_be_false()
530530
server_ctx.complete.should_be_true()
531531

532532
client_ctx.lifetime.should_be_at_most(400)
533533
client_ctx.target_name.should_be(self.target_name)
534-
client_ctx.mech_type.should_be_a(gb.OID)
534+
client_ctx.mech.should_be_a(gb.OID)
535535
client_ctx.actual_flags.should_be_a(gb.IntEnumFlagSet)
536536
client_ctx.locally_initiated.should_be_true()
537537
client_ctx.complete.should_be_true()

gssapi/tests/test_raw.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def test_store_cred_acquire_cred(self):
320320

321321
store_res.shouldnt_be_none()
322322
store_res.usage.should_be('initiate')
323-
store_res.mech_types.should_include(gb.MechType.kerberos)
323+
store_res.mechs.should_include(gb.MechType.kerberos)
324324

325325
deleg_name = gb.inquire_cred(deleg_creds).name
326326
acq_resp = gb.acquire_cred(deleg_name, usage='initiate')
@@ -343,7 +343,7 @@ def test_store_cred_into_acquire_cred(self):
343343
# NB(sross): overwrite because the ccache doesn't exist yet
344344
store_res = gb.store_cred_into(store, initial_creds, overwrite=True)
345345

346-
store_res.mech_types.shouldnt_be_none()
346+
store_res.mechs.shouldnt_be_none()
347347
store_res.usage.should_be('initiate')
348348

349349
name = gb.import_name(princ_name.encode('UTF-8'))

0 commit comments

Comments
 (0)