コード例 #1
0
ファイル: test_cli.py プロジェクト: mzedel/useradm
    def test_set_password(self, api_client_mgmt, cli, clean_db):
        password = '******'
        new_password = '******'
        email = '*****@*****.**'
        tenant = 'tenant1id'

        users_db = {tenant: [email]}

        cli.create_user(email, password, tenant_id=tenant)

        with tenantadm.run_fake_user_tenants(users_db):
            _, r = api_client_mgmt.login(email, password)
            assert r.status_code == 200

            cli.set_password(email, new_password, tenant)
            status_code = 200
            try:
                _, r = api_client_mgmt.login(email, password)
            except bravado.exception.HTTPError as e:
                assert e.response.status_code == 401
                status_code = 401
            assert status_code == 401
            _, r = api_client_mgmt.login(email, new_password)
            assert r.status_code == 200

            token = r.text
            assert token
            _, claims, _ = explode_jwt(token)
            assert claims['mender.tenant'] == tenant
コード例 #2
0
 def test_create_user_with_id(self, api_client_mgmt, cli, clean_db):
     cli.create_user("*****@*****.**", "1234youseeme", user_id="123456")
     users = api_client_mgmt.get_users()
     assert [
         user for user in users
         if user.email == "*****@*****.**" and user.id == "123456"
     ]
コード例 #3
0
    def test_set_password(self, api_client_mgmt, cli, clean_db):
        user = {
            "password": "******",
            "new_password": "******",
            "email": "*****@*****.**",
            "tenant": TENANT_ONE,
        }

        users_db = {user["tenant"]: [user["email"]]}

        with tenantadm.run_fake_create_user(user):
            cli.create_user(user["email"],
                            user["password"],
                            tenant_id=user["tenant"])

        with tenantadm.run_fake_user_tenants(users_db):
            _, r = api_client_mgmt.login(user["email"], user["password"])
            assert r.status_code == 200

            cli.set_password(user["email"], user["new_password"],
                             user["tenant"])
            status_code = 200
            try:
                _, r = api_client_mgmt.login(user["email"], user["password"])
            except bravado.exception.HTTPError as e:
                assert e.response.status_code == 401
                status_code = 401
            assert status_code == 401
            _, r = api_client_mgmt.login(user["email"], user["new_password"])
            assert r.status_code == 200

            token = r.text
            assert token
            _, claims, _ = explode_jwt(token)
            assert claims["mender.tenant"] == user["tenant"]
コード例 #4
0
ファイル: test_cli.py プロジェクト: mzedel/useradm
    def test_create_user_login(self, api_client_mgmt, cli, clean_db):
        email = '*****@*****.**'
        password = '******'
        cli.create_user(email, password)
        _, r = api_client_mgmt.login(email, password)
        assert r.status_code == 200

        token = r.text
        assert token
コード例 #5
0
ファイル: test_cli.py プロジェクト: mzedel/useradm
    def test_create_user(self, api_client_mgmt, cli):
        cli.create_user('*****@*****.**', '1234youseeme',
                        tenant_id='tenant1id')

        users = api_client_mgmt.get_users(make_auth('foo', tenant='tenant1id'))
        assert [user for user in users if user.email == '*****@*****.**']

        other_tenant_users = api_client_mgmt.get_users(make_auth('foo',
                                                                 tenant='tenant2id'))
        assert not other_tenant_users
コード例 #6
0
    def test_create_user(self, api_client_mgmt, cli):
        cli.create_user("*****@*****.**",
                        "1234youseeme",
                        tenant_id="tenant1id")

        users = api_client_mgmt.get_users(make_auth("foo", tenant="tenant1id"))
        assert [
            user for user in users if user.email == "*****@*****.**"
        ]

        other_tenant_users = api_client_mgmt.get_users(
            make_auth("foo", tenant="tenant2id"))
        assert not other_tenant_users
コード例 #7
0
ファイル: test_cli.py プロジェクト: mzedel/useradm
 def test_set_password(self, api_client_mgmt, cli, clean_db):
     password = '******'
     new_password = '******'
     email = '*****@*****.**'
     cli.create_user(email, password)
     _, r = api_client_mgmt.login(email, password)
     assert r.status_code == 200
     cli.set_password(email, new_password)
     status_code = 200
     try:
         _, r = api_client_mgmt.login(email, password)
     except bravado.exception.HTTPError as e:
         assert e.response.status_code == 401
         status_code = 401
     assert status_code == 401
     _, r = api_client_mgmt.login(email, new_password)
     assert r.status_code == 200
コード例 #8
0
ファイル: test_cli.py プロジェクト: mzedel/useradm
    def test_create_user_login(self, api_client_mgmt, cli, clean_db):
        email = '*****@*****.**'
        password = '******'
        tenant = 'tenant1id'

        users_db = {tenant: [email]}

        cli.create_user(email, password, tenant_id=tenant)

        with tenantadm.run_fake_user_tenants(users_db):
            _, r = api_client_mgmt.login(email, password)
            assert r.status_code == 200

            token = r.text
            assert token
            _, claims, _ = explode_jwt(token)
            assert claims['mender.tenant'] == tenant
コード例 #9
0
    def test_create_user_login(self, api_client_mgmt, cli, clean_db):
        user = {"email": "*****@*****.**", "password": "******"}

        users_db = {TENANT_ONE: [user["email"]]}

        with tenantadm.run_fake_create_user(user):
            cli.create_user(user["email"],
                            user["password"],
                            tenant_id=TENANT_ONE)

        with tenantadm.run_fake_user_tenants(users_db):
            _, r = api_client_mgmt.login(user["email"], user["password"])
            assert r.status_code == 200

            token = r.text
            assert token
            _, claims, _ = explode_jwt(token)
            assert claims["mender.tenant"] == TENANT_ONE
コード例 #10
0
    def test_create_user(self, api_client_mgmt, cli):
        user = {
            "email": f"foo-{TENANT_ONE}@bar.com",
            "password": "******"
        }

        with tenantadm.run_fake_create_user(user):
            cli.create_user(user["email"],
                            user["password"],
                            tenant_id=TENANT_ONE)

        users = api_client_mgmt.get_users(make_auth("foo", tenant=TENANT_ONE))
        assert [
            user for user in users if user.email == f"foo-{TENANT_ONE}@bar.com"
        ]

        other_tenant_users = api_client_mgmt.get_users(
            make_auth("foo", tenant=TENANT_TWO))
        assert not other_tenant_users
コード例 #11
0
ファイル: test_cli.py プロジェクト: mzedel/useradm
 def test_create_user_with_id(self, api_client_mgmt, cli, clean_db):
     cli.create_user('*****@*****.**', '1234youseeme', user_id='123456')
     users = api_client_mgmt.get_users()
     assert [user for user in users \
             if user.email == '*****@*****.**' and user.id == '123456']
コード例 #12
0
ファイル: test_cli.py プロジェクト: mzedel/useradm
 def test_create_user(self, api_client_mgmt, cli, clean_db):
     cli.create_user('*****@*****.**', '1234youseeme')
     users = api_client_mgmt.get_users()
     assert [user for user in users if user.email == '*****@*****.**']