Esempio n. 1
0
 def test_tokens_limit_for_single_user(self, tenant_id, api_client_mgmt,
                                       init_users_mt):
     users_db = {
         tenant: [user.email for user in users]
         for tenant, users in init_users_mt.items()
     }
     with tenantadm.run_fake_user_tenants(users_db):
         self._test_pat_limit(api_client_mgmt, init_users_mt[tenant_id])
Esempio n. 2
0
 def test_tokens_naming_collisions_one_user(self, tenant_id,
                                            api_client_mgmt, init_users_mt):
     users_db = {
         tenant: [user.email for user in users]
         for tenant, users in init_users_mt.items()
     }
     with tenantadm.run_fake_user_tenants(users_db):
         self._test_pat_name_collision_for_one_user(
             api_client_mgmt, init_users_mt[tenant_id])
Esempio n. 3
0
    def test_ok(self, tenant_id, api_client_int, api_client_mgmt,
                init_users_mt):
        token_request = {
            "name": "my_personal_access_token",
            "expires_in": 3600
        }
        users_db = {
            tenant: [user.email for user in users]
            for tenant, users in init_users_mt.items()
        }

        with tenantadm.run_fake_user_tenants(users_db):
            self._do_test_ok(api_client_int, api_client_mgmt,
                             init_users_mt[tenant_id], token_request)
Esempio n. 4
0
    def test_ok(self, api_client_mgmt, init_users_mt):
        password = "******"

        users_db = { tenant: [user.email for user in users] \
                     for tenant, users in init_users_mt.items() }

        with tenantadm.run_fake_user_tenants(users_db):
            for tenant, users in users_db.items():
                for email in users:
                    _, r = api_client_mgmt.login(email, password)
                    assert r.status_code == 200
                    assert r.headers['Content-Type'] == "application/jwt"
                    _, claims, _ = explode_jwt(r.text)
                    assert claims['mender.tenant'] == tenant
Esempio n. 5
0
    def test_suspended_tenant(self, api_client_mgmt, init_users_mt):
        password = "******"

        users_db = { tenant: [user.email for user in users] \
                     for tenant, users in init_users_mt.items() }

        with tenantadm.run_fake_user_tenants(users_db, status='suspended'):
            for tenant, users in users_db.items():
                try:
                    for email in users:
                        _, r = api_client_mgmt.login(email, password)
                        assert r.status_code == 401
                except bravado.exception.HTTPError as herr:
                    assert herr.response.status_code == 401
                    assert herr.swagger_result.error == 'tenant account suspended'