Exemplo n.º 1
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
Exemplo n.º 2
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
Exemplo n.º 3
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"
     ]
Exemplo n.º 4
0
    def _do_test_no_users(self, api_client_mgmt, tenant_id=None):
        auth = None
        if tenant_id is not None:
            auth = make_auth("foo", tenant_id)

        users = api_client_mgmt.get_users(auth)
        assert len(users) == 0
Exemplo n.º 5
0
    def _do_test_ok_email_or_pass(self,
                                  api_client_mgmt,
                                  init_users,
                                  user,
                                  update,
                                  tenant_id=None):
        auth = None
        if tenant_id is not None:
            auth = make_auth("foo", tenant_id)

        # test update
        _, r = api_client_mgmt.update_user(user.id, update, auth)
        assert r.status_code == 204

        # get/verify users
        users = api_client_mgmt.get_users(auth)
        assert len(users) == len(init_users)

        # find the user via (new?) email
        email = user.email
        new_email = update.get("email", None)
        if new_email != None and new_email != user.email:
            email = new_email

        found = [u for u in users if u.email == email]
        assert len(found) == 1

        # try if login still works
        _, r = api_client_mgmt.login(email, update["password"])

        assert r.status_code == 200
Exemplo n.º 6
0
    def _do_test_ok_email_or_pass(self,
                                  api_client_mgmt,
                                  init_users,
                                  user,
                                  update,
                                  tenant_id=None):
        _, r = api_client_mgmt.login(user.email, 'correcthorsebatterystaple')
        assert r.status_code == 200
        token = r.text
        auth = {"Authorization": "Bearer " + token}

        # test update
        _, r = api_client_mgmt.update_user(user.id, update, auth)
        assert r.status_code == 204

        # get/verify users
        users = api_client_mgmt.get_users(auth)
        assert len(users) == len(init_users)

        # find the user via (new?) email
        email = user.email
        new_email = update.get("email", None)
        if new_email != None and new_email != user.email:
            email = new_email

        found = [u for u in users if u.email == email]
        assert len(found) == 1

        # try if login still works
        _, r = api_client_mgmt.login(email, update["password"])

        assert r.status_code == 200
Exemplo n.º 7
0
    def test_ok(self, api_client_int,api_client_mgmt, clean_db, ):
        user = {"email":"*****@*****.**", "password":"******"}

        with tenantadm.run_fake_create_user(user):
            api_client_int.create_user_for_tenant('foobar', user)

        auth = make_auth("foo", 'foobar')
        users = api_client_mgmt.get_users(auth)
        assert len(users) == 1
Exemplo n.º 8
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
Exemplo n.º 9
0
    def test_ok_pwd_hash(self, api_client_int, api_client_mgmt, clean_db_f):
        user = {
            "email": "*****@*****.**",
            "password_hash": "secret12345",
            "propagate": False,
        }

        with tenantadm.run_fake_create_user(user):
            api_client_int.create_user_for_tenant("foobar", user)

        auth = make_auth("foo", "foobar")
        users = api_client_mgmt.get_users(auth)
        assert len(users) == 1
Exemplo n.º 10
0
    def _do_test_ok(self, api_client_mgmt, init_users, tenant_id=None):
        auth = None
        if tenant_id is not None:
            auth = make_auth("foo", tenant_id)

        rsp = api_client_mgmt.delete_user(init_users[0]['id'], auth)
        assert rsp.status_code == 204

        users = api_client_mgmt.get_users(auth)
        assert len(users) == len(init_users) - 1

        found = [u for u in users if u.id == init_users[0]['id']]
        assert len(found) == 0
Exemplo n.º 11
0
    def _do_test_ok(self, api_client_mgmt, init_users, new_user, tenant_id=None):
        auth = None
        if tenant_id is not None:
            auth = make_auth("foo", tenant_id)

        _, r = api_client_mgmt.create_user(new_user, auth)
        assert r.status_code == 201

        users = api_client_mgmt.get_users(auth)
        assert len(users) == len(init_users) + 1

        found_user = [u for u in users if u.email == new_user["email"]]
        assert len(found_user) == 1
        found_user = found_user[0]
Exemplo n.º 12
0
    def _do_test_ok_email(
        self, api_client_mgmt, init_users, user, update, tenant_id=None
    ):
        _, r = api_client_mgmt.login(user.email, "correcthorsebatterystaple")
        assert r.status_code == 200
        token = r.text
        auth = {"Authorization": "Bearer " + token}

        # test update
        _, r = api_client_mgmt.update_user(user.id, update, auth)
        assert r.status_code == 204

        # get/verify users
        users = api_client_mgmt.get_users(auth)
        assert len(users) == len(init_users)

        found = [u for u in users if u.email == update["email"]]
        assert len(found) == 1
Exemplo n.º 13
0
    def _do_test_ok_email(self,
                          api_client_mgmt,
                          init_users,
                          user,
                          update,
                          tenant_id=None):
        auth = None
        if tenant_id is not None:
            auth = make_auth("foo", tenant_id)

        # test update
        _, r = api_client_mgmt.update_user(user.id, update, auth)
        assert r.status_code == 204

        # get/verify users
        users = api_client_mgmt.get_users(auth)
        assert len(users) == len(init_users)

        found = [u for u in users if u.email == update["email"]]
        assert len(found) == 1
Exemplo n.º 14
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']
Exemplo n.º 15
0
 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 == '*****@*****.**']