コード例 #1
0
    def test_acquire_creds_impersonate_name(self):
        target_name = gb.importName(TARGET_SERVICE_NAME)
        client_ctx_resp = gb.initSecContext(target_name)
        client_token = client_ctx_resp[3]
        del client_ctx_resp  # free all the things (except the token)!

        server_name = gb.importName(SERVICE_PRINCIPAL,
                                    gb.NameType.principal)
        server_creds = gb.acquireCred(server_name, cred_usage='both')[0]
        server_ctx_resp = gb.acceptSecContext(client_token,
                                              acceptor_cred=server_creds)

        imp_resp = gb.acquireCredImpersonateName(server_creds,
                                                 server_ctx_resp[1])

        imp_resp.shouldnt_be_none()

        imp_creds, actual_mechs, output_ttl = imp_resp

        imp_creds.shouldnt_be_none()
        imp_creds.should_be_a(gb.Creds)

        actual_mechs.shouldnt_be_empty()
        actual_mechs.should_include(gb.MechType.kerberos)

        output_ttl.should_be_a(int)
コード例 #2
0
    def test_compare_name(self):
        service_name1 = gb.importName(TARGET_SERVICE_NAME)
        service_name2 = gb.importName(TARGET_SERVICE_NAME)
        init_name = gb.importName(INITIATOR_PRINCIPAL, gb.NameType.principal)

        gb.compareName(service_name1, service_name2).should_be_true()
        gb.compareName(service_name2, service_name1).should_be_true()

        gb.compareName(service_name1, init_name).should_be_false()

        gb.releaseName(service_name1)
        gb.releaseName(service_name2)
        gb.releaseName(init_name)
コード例 #3
0
ファイル: test_base.py プロジェクト: admiyo/python-gssapi
    def test_compare_name(self):
        service_name1 = gb.importName(TARGET_SERVICE_NAME)
        service_name2 = gb.importName(TARGET_SERVICE_NAME)
        init_name = gb.importName(INITIATOR_PRINCIPAL, gb.NameType.principal)

        gb.compareName(service_name1, service_name2).should_be_true()
        gb.compareName(service_name2, service_name1).should_be_true()

        gb.compareName(service_name1, init_name).should_be_false()

        gb.releaseName(service_name1)
        gb.releaseName(service_name2)
        gb.releaseName(init_name)
コード例 #4
0
    def setUp(self):
        self.target_name = gb.importName(TARGET_SERVICE_NAME)
        ctx_resp = gb.initSecContext(self.target_name)

        self.client_token = ctx_resp[3]
        self.client_ctx = ctx_resp[0]
        self.client_ctx.shouldnt_be_none()

        self.server_name = gb.importName(SERVICE_PRINCIPAL,
                                         gb.NameType.principal)
        self.server_creds = gb.acquireCred(self.server_name)[0]

        self.server_ctx = None
コード例 #5
0
    def setUp(self):
        self.target_name = gb.importName(TARGET_SERVICE_NAME)
        ctx_resp = gb.initSecContext(self.target_name)

        self.client_token = ctx_resp[3]
        self.client_ctx = ctx_resp[0]
        self.client_ctx.shouldnt_be_none()

        str_server_name = (TARGET_SERVICE_NAME + b'/' +
                           socket.getfqdn().encode('utf-8'))
        self.server_name = gb.importName(str_server_name,
                                         gb.NameType.principal)
        self.server_creds = gb.acquireCred(self.server_name)[0]

        self.server_ctx = None
コード例 #6
0
ファイル: test_base.py プロジェクト: admiyo/python-gssapi
    def setUp(self):
        self.target_name = gb.importName(TARGET_SERVICE_NAME)
        ctx_resp = gb.initSecContext(self.target_name)

        self.client_token = ctx_resp[3]
        self.client_ctx = ctx_resp[0]
        self.client_ctx.shouldnt_be_none()

        str_server_name = (TARGET_SERVICE_NAME + b'/' +
                           socket.getfqdn().encode('utf-8'))
        self.server_name = gb.importName(str_server_name,
                                         gb.NameType.principal)
        self.server_creds = gb.acquireCred(self.server_name)[0]

        self.server_ctx = None
コード例 #7
0
ファイル: test_client.py プロジェクト: admiyo/python-gssapi
 def __init__(self):
     self.ctx = None
     str_server_name = (TARGET_SERVICE_NAME.encode('utf-8') + b'/' +
                        socket.getfqdn().encode('utf-8'))
     self.server_name = gb.importName(str_server_name,
                                      gb.NameType.principal)
     self.server_creds = gb.acquireCred(self.server_name)[0]
コード例 #8
0
ファイル: test_base.py プロジェクト: admiyo/python-gssapi
    def test_import_name(self):
        imported_name = gb.importName(TARGET_SERVICE_NAME)

        imported_name.shouldnt_be_none()
        imported_name.should_be_a(gb.Name)

        gb.releaseName(imported_name)
コード例 #9
0
    def test_import_name(self):
        imported_name = gb.importName(TARGET_SERVICE_NAME)

        imported_name.shouldnt_be_none()
        imported_name.should_be_a(gb.Name)

        gb.releaseName(imported_name)
コード例 #10
0
 def __init__(self):
     self.ctx = None
     str_server_name = (TARGET_SERVICE_NAME.encode('utf-8') + b'/' +
                        socket.getfqdn().encode('utf-8'))
     self.server_name = gb.importName(str_server_name,
                                      gb.NameType.principal)
     self.server_creds = gb.acquireCred(self.server_name)[0]
コード例 #11
0
ファイル: test_base.py プロジェクト: admiyo/python-gssapi
    def test_inquire_context(self):
        target_name = gb.importName(TARGET_SERVICE_NAME)
        ctx_resp = gb.initSecContext(target_name)

        client_token1 = ctx_resp[3]
        client_ctx = ctx_resp[0]
        str_server_name = (TARGET_SERVICE_NAME + b'/' +
                           socket.getfqdn().encode('utf-8'))
        server_name = gb.importName(str_server_name,
                                    gb.NameType.principal)
        server_creds = gb.acquireCred(server_name)[0]
        server_resp = gb.acceptSecContext(client_token1,
                                          acceptor_cred=server_creds)
        server_tok = server_resp[3]

        client_resp2 = gb.initSecContext(target_name,
                                         context=client_ctx,
                                         input_token=server_tok)
        ctx = client_resp2[0]

        inq_resp = gb.inquireContext(ctx)
        inq_resp.shouldnt_be_none()

        (src_name, target_name, ttl, mech_type,
         flags, local_est, is_open) = inq_resp

        src_name.shouldnt_be_none()
        src_name.should_be_a(gb.Name)

        target_name.shouldnt_be_none()
        target_name.should_be_a(gb.Name)

        ttl.should_be_an_integer()

        mech_type.shouldnt_be_none()
        mech_type.should_be(gb.MechType.kerberos)

        flags.shouldnt_be_none()
        flags.should_be_a(list)
        flags.shouldnt_be_empty()

        local_est.should_be_a(bool)
        local_est.should_be_true()

        is_open.should_be_a(bool)
        is_open.should_be_true()
コード例 #12
0
    def __new__(cls, name=None, name_type=gss.NameType.hostbased_service,
                base_name=None):
        if base_name is None:
            base_res = gss.importName(name.encode('utf-8'), name_type)
        else:
            base_res = base_name

        return super(GSSName, cls).__new__(cls, base_res)
コード例 #13
0
    def test_inquire_context(self):
        target_name = gb.importName(TARGET_SERVICE_NAME)
        ctx_resp = gb.initSecContext(target_name)

        client_token1 = ctx_resp[3]
        client_ctx = ctx_resp[0]
        str_server_name = (TARGET_SERVICE_NAME + b'/' +
                           socket.getfqdn().encode('utf-8'))
        server_name = gb.importName(str_server_name, gb.NameType.principal)
        server_creds = gb.acquireCred(server_name)[0]
        server_resp = gb.acceptSecContext(client_token1,
                                          acceptor_cred=server_creds)
        server_tok = server_resp[3]

        client_resp2 = gb.initSecContext(target_name,
                                         context=client_ctx,
                                         input_token=server_tok)
        ctx = client_resp2[0]

        inq_resp = gb.inquireContext(ctx)
        inq_resp.shouldnt_be_none()

        (src_name, target_name, ttl, mech_type, flags, local_est,
         is_open) = inq_resp

        src_name.shouldnt_be_none()
        src_name.should_be_a(gb.Name)

        target_name.shouldnt_be_none()
        target_name.should_be_a(gb.Name)

        ttl.should_be_an_integer()

        mech_type.shouldnt_be_none()
        mech_type.should_be(gb.MechType.kerberos)

        flags.shouldnt_be_none()
        flags.should_be_a(list)
        flags.shouldnt_be_empty()

        local_est.should_be_a(bool)
        local_est.should_be_true()

        is_open.should_be_a(bool)
        is_open.should_be_true()
コード例 #14
0
    def setUp(self):
        self.target_name = gb.importName(TARGET_SERVICE_NAME)
        ctx_resp = gb.initSecContext(self.target_name)

        self.client_token1 = ctx_resp[3]
        self.client_ctx = ctx_resp[0]
        self.server_name = gb.importName(SERVICE_PRINCIPAL,
                                         gb.NameType.principal)
        self.server_creds = gb.acquireCred(self.server_name)[0]
        server_resp = gb.acceptSecContext(self.client_token1,
                                          acceptor_cred=self.server_creds)
        self.server_ctx = server_resp[0]
        self.server_tok = server_resp[3]

        client_resp2 = gb.initSecContext(self.target_name,
                                         context=self.client_ctx,
                                         input_token=self.server_tok)
        self.client_token2 = client_resp2[3]
        self.client_ctx = client_resp2[0]
コード例 #15
0
    def __new__(cls,
                name,
                name_type=gss.NameType.hostbased_service,
                base_name=None):
        if base_name is None:
            base_res = gss.importName(name.encode('utf-8'), name_type)
        else:
            base_res = base_name

        return super(GSSName, cls).__new__(cls, base_res)
コード例 #16
0
    def setUp(self):
        self.target_name = gb.importName(TARGET_SERVICE_NAME)
        ctx_resp = gb.initSecContext(self.target_name)

        self.client_token1 = ctx_resp[3]
        self.client_ctx = ctx_resp[0]
        str_server_name = (TARGET_SERVICE_NAME + b'/' +
                           socket.getfqdn().encode('utf-8'))
        self.server_name = gb.importName(str_server_name,
                                         gb.NameType.principal)
        self.server_creds = gb.acquireCred(self.server_name)[0]
        server_resp = gb.acceptSecContext(self.client_token1,
                                          acceptor_cred=self.server_creds)
        self.server_ctx = server_resp[0]
        self.server_tok = server_resp[3]

        client_resp2 = gb.initSecContext(self.target_name,
                                         context=self.client_ctx,
                                         input_token=self.server_tok)
        self.client_token2 = client_resp2[3]
        self.client_ctx = client_resp2[0]
コード例 #17
0
ファイル: test_base.py プロジェクト: admiyo/python-gssapi
    def setUp(self):
        self.target_name = gb.importName(TARGET_SERVICE_NAME)
        ctx_resp = gb.initSecContext(self.target_name)

        self.client_token1 = ctx_resp[3]
        self.client_ctx = ctx_resp[0]
        str_server_name = (TARGET_SERVICE_NAME + b'/' +
                           socket.getfqdn().encode('utf-8'))
        self.server_name = gb.importName(str_server_name,
                                         gb.NameType.principal)
        self.server_creds = gb.acquireCred(self.server_name)[0]
        server_resp = gb.acceptSecContext(self.client_token1,
                                          acceptor_cred=self.server_creds)
        self.server_ctx = server_resp[0]
        self.server_tok = server_resp[3]

        client_resp2 = gb.initSecContext(self.target_name,
                                         context=self.client_ctx,
                                         input_token=self.server_tok)
        self.client_token2 = client_resp2[3]
        self.client_ctx = client_resp2[0]
コード例 #18
0
    def test_context_time(self):
        target_name = gb.importName(TARGET_SERVICE_NAME)
        ctx_resp = gb.initSecContext(target_name)

        client_token1 = ctx_resp[3]
        client_ctx = ctx_resp[0]
        server_name = gb.importName(SERVICE_PRINCIPAL,
                                    gb.NameType.principal)
        server_creds = gb.acquireCred(server_name)[0]
        server_resp = gb.acceptSecContext(client_token1,
                                          acceptor_cred=server_creds)
        server_tok = server_resp[3]

        client_resp2 = gb.initSecContext(target_name,
                                         context=client_ctx,
                                         input_token=server_tok)
        ctx = client_resp2[0]

        ttl = gb.contextTime(ctx)

        ttl.should_be_an_integer()
        ttl.should_be_greater_than(0)
コード例 #19
0
    def test_context_time(self):
        target_name = gb.importName(TARGET_SERVICE_NAME)
        ctx_resp = gb.initSecContext(target_name)

        client_token1 = ctx_resp[3]
        client_ctx = ctx_resp[0]
        str_server_name = (TARGET_SERVICE_NAME + b'/' +
                           socket.getfqdn().encode('utf-8'))
        server_name = gb.importName(str_server_name, gb.NameType.principal)
        server_creds = gb.acquireCred(server_name)[0]
        server_resp = gb.acceptSecContext(client_token1,
                                          acceptor_cred=server_creds)
        server_tok = server_resp[3]

        client_resp2 = gb.initSecContext(target_name,
                                         context=client_ctx,
                                         input_token=server_tok)
        ctx = client_resp2[0]

        ttl = gb.contextTime(ctx)

        ttl.should_be_an_integer()
        ttl.should_be_greater_than(0)
コード例 #20
0
ファイル: test_base.py プロジェクト: admiyo/python-gssapi
    def test_display_name(self):
        imported_name = gb.importName(TARGET_SERVICE_NAME)
        displ_resp = gb.displayName(imported_name)

        displ_resp.shouldnt_be_none()

        (displayed_name, out_type) = displ_resp

        displayed_name.shouldnt_be_none()
        displayed_name.should_be_a(bytes)
        displayed_name.should_be(TARGET_SERVICE_NAME)

        out_type.shouldnt_be_none()
        out_type.should_be(gb.NameType.hostbased_service)
コード例 #21
0
    def test_display_name(self):
        imported_name = gb.importName(TARGET_SERVICE_NAME)
        displ_resp = gb.displayName(imported_name)

        displ_resp.shouldnt_be_none()

        (displayed_name, out_type) = displ_resp

        displayed_name.shouldnt_be_none()
        displayed_name.should_be_a(bytes)
        displayed_name.should_be(TARGET_SERVICE_NAME)

        out_type.shouldnt_be_none()
        out_type.should_be(gb.NameType.hostbased_service)
コード例 #22
0
ファイル: test_base.py プロジェクト: admiyo/python-gssapi
    def test_canonicalize_export_name(self):
        imported_name = gb.importName(INITIATOR_PRINCIPAL,
                                      gb.NameType.principal)

        canonicalized_name = gb.canonicalizeName(imported_name,
                                                 gb.MechType.kerberos)

        canonicalized_name.shouldnt_be_none()
        canonicalized_name.should_be_a(gb.Name)

        exported_name = gb.exportName(canonicalized_name)

        exported_name.shouldnt_be_none()
        exported_name.should_be_a(bytes)
        exported_name.shouldnt_be_empty()
コード例 #23
0
    def test_canonicalize_export_name(self):
        imported_name = gb.importName(INITIATOR_PRINCIPAL,
                                      gb.NameType.principal)

        canonicalized_name = gb.canonicalizeName(imported_name,
                                                 gb.MechType.kerberos)

        canonicalized_name.shouldnt_be_none()
        canonicalized_name.should_be_a(gb.Name)

        exported_name = gb.exportName(canonicalized_name)

        exported_name.shouldnt_be_none()
        exported_name.should_be_a(bytes)
        exported_name.shouldnt_be_empty()
コード例 #24
0
    def test_acquire_creds(self):
        name = gb.importName(SERVICE_PRINCIPAL,
                             gb.NameType.principal)
        cred_resp = gb.acquireCred(name)
        cred_resp.shouldnt_be_none()

        (creds, actual_mechs, ttl) = cred_resp

        creds.shouldnt_be_none()
        creds.should_be_a(gb.Creds)

        actual_mechs.shouldnt_be_empty()
        actual_mechs.should_include(gb.MechType.kerberos)

        ttl.should_be_an_integer()

        gb.releaseName(name)
        gb.releaseCred(creds)
コード例 #25
0
    def test_acquire_creds(self):
        name = gb.importName(
            (TARGET_SERVICE_NAME + b'/' + socket.getfqdn().encode('utf-8')),
            gb.NameType.principal)
        cred_resp = gb.acquireCred(name)
        cred_resp.shouldnt_be_none()

        (creds, actual_mechs, ttl) = cred_resp

        creds.shouldnt_be_none()
        creds.should_be_a(gb.Creds)

        actual_mechs.shouldnt_be_empty()
        actual_mechs.should_include(gb.MechType.kerberos)

        ttl.should_be_an_integer()

        gb.releaseName(name)
        gb.releaseCred(creds)
コード例 #26
0
ファイル: test_base.py プロジェクト: admiyo/python-gssapi
    def test_acquire_creds(self):
        name = gb.importName((TARGET_SERVICE_NAME + b'/' +
                              socket.getfqdn().encode('utf-8')),
                             gb.NameType.principal)
        cred_resp = gb.acquireCred(name)
        cred_resp.shouldnt_be_none()

        (creds, actual_mechs, ttl) = cred_resp

        creds.shouldnt_be_none()
        creds.should_be_a(gb.Creds)

        actual_mechs.shouldnt_be_empty()
        actual_mechs.should_include(gb.MechType.kerberos)

        ttl.should_be_an_integer()

        gb.releaseName(name)
        gb.releaseCred(creds)
コード例 #27
0
 def setUp(self):
     self.target_name = gb.importName(TARGET_SERVICE_NAME)
コード例 #28
0
    def test_duplicate_name(self):
        orig_name = gb.importName(TARGET_SERVICE_NAME)
        new_name = gb.duplicateName(orig_name)

        new_name.shouldnt_be_none()
        gb.compareName(orig_name, new_name).should_be_true()
コード例 #29
0
ファイル: test_base.py プロジェクト: admiyo/python-gssapi
 def setUp(self):
     self.target_name = gb.importName(TARGET_SERVICE_NAME)
コード例 #30
0
ファイル: test_base.py プロジェクト: admiyo/python-gssapi
    def test_duplicate_name(self):
        orig_name = gb.importName(TARGET_SERVICE_NAME)
        new_name = gb.duplicateName(orig_name)

        new_name.shouldnt_be_none()
        gb.compareName(orig_name, new_name).should_be_true()