Esempio n. 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)
Esempio n. 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)
Esempio n. 3
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)
Esempio n. 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
Esempio n. 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
Esempio n. 6
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
Esempio n. 7
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]
Esempio n. 8
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)
Esempio n. 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)
Esempio n. 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]
Esempio n. 11
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()
Esempio n. 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)
Esempio n. 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()
Esempio n. 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]
Esempio n. 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)
Esempio n. 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]
Esempio n. 17
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]
Esempio n. 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)
Esempio n. 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)
Esempio n. 20
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)
Esempio n. 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)
Esempio n. 22
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()
Esempio n. 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()
Esempio n. 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)
Esempio n. 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)
Esempio n. 26
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)
Esempio n. 27
0
 def setUp(self):
     self.target_name = gb.importName(TARGET_SERVICE_NAME)
Esempio n. 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()
Esempio n. 29
0
 def setUp(self):
     self.target_name = gb.importName(TARGET_SERVICE_NAME)
Esempio n. 30
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()