|
8 | 8 |
|
9 | 9 | import gssapi.raw as gb
|
10 | 10 | import gssapi.raw.misc as gbmisc
|
11 |
| -from gssapi.tests._utils import _extension_test |
| 11 | +from gssapi.tests._utils import _extension_test, _minversion_test |
12 | 12 | from gssapi.tests import k5test as kt
|
13 | 13 |
|
14 | 14 |
|
@@ -307,6 +307,27 @@ def test_acquire_creds_impersonate_name(self):
|
307 | 307 | # no need to explicitly release any more -- we can just rely on
|
308 | 308 | # __dealloc__ (b/c cython)
|
309 | 309 |
|
| 310 | + @_extension_test('s4u', 'S4U') |
| 311 | + @_minversion_test('1.11', 'returning delegated S4U2Proxy credentials') |
| 312 | + def test_always_get_delegated_creds(self): |
| 313 | + svc_princ = SERVICE_PRINCIPAL.decode("UTF-8") |
| 314 | + self.realm.kinit(svc_princ, flags=['-k', '-f']) |
| 315 | + |
| 316 | + target_name = gb.import_name(TARGET_SERVICE_NAME, |
| 317 | + gb.NameType.hostbased_service) |
| 318 | + |
| 319 | + client_token = gb.init_sec_context(target_name).token |
| 320 | + |
| 321 | + # if our acceptor creds have a usage of both, we get |
| 322 | + # s4u2proxy delegated credentials |
| 323 | + server_creds = gb.acquire_cred(None, usage='both').creds |
| 324 | + server_ctx_resp = gb.accept_sec_context(client_token, |
| 325 | + acceptor_creds=server_creds) |
| 326 | + |
| 327 | + server_ctx_resp.shouldnt_be_none() |
| 328 | + server_ctx_resp.delegated_creds.shouldnt_be_none() |
| 329 | + server_ctx_resp.delegated_creds.should_be_a(gb.Creds) |
| 330 | + |
310 | 331 | @_extension_test('rfc5588', 'RFC 5588')
|
311 | 332 | def test_store_cred_acquire_cred(self):
|
312 | 333 | # we need to acquire a forwardable ticket
|
@@ -699,6 +720,33 @@ def tearDown(self):
|
699 | 720 | if self.server_ctx is not None:
|
700 | 721 | gb.delete_sec_context(self.server_ctx)
|
701 | 722 |
|
| 723 | + def test_basic_accept_context_no_acceptor_creds(self): |
| 724 | + server_resp = gb.accept_sec_context(self.client_token) |
| 725 | + server_resp.shouldnt_be_none() |
| 726 | + |
| 727 | + (self.server_ctx, name, mech_type, out_token, |
| 728 | + out_req_flags, out_ttl, delegated_cred, cont_needed) = server_resp |
| 729 | + |
| 730 | + self.server_ctx.shouldnt_be_none() |
| 731 | + self.server_ctx.should_be_a(gb.SecurityContext) |
| 732 | + |
| 733 | + name.shouldnt_be_none() |
| 734 | + name.should_be_a(gb.Name) |
| 735 | + |
| 736 | + mech_type.should_be(gb.MechType.kerberos) |
| 737 | + |
| 738 | + out_token.shouldnt_be_empty() |
| 739 | + |
| 740 | + out_req_flags.should_be_a(collections.Set) |
| 741 | + out_req_flags.should_be_at_least_length(2) |
| 742 | + |
| 743 | + out_ttl.should_be_greater_than(0) |
| 744 | + |
| 745 | + if delegated_cred is not None: |
| 746 | + delegated_cred.should_be_a(gb.Creds) |
| 747 | + |
| 748 | + cont_needed.should_be_a(bool) |
| 749 | + |
702 | 750 | def test_basic_accept_context(self):
|
703 | 751 | server_resp = gb.accept_sec_context(self.client_token,
|
704 | 752 | acceptor_creds=self.server_creds)
|
|
0 commit comments