def test_create_hashed_id_persisted(client: FlaskClient) -> None: # GIVEN email = VALID_EMAIL # WHEN create_user_successfully(client) # THEN user = get_user_by_email(email) assert bcrypt.checkpw(str(user.id).encode("utf-8"), user.hashed_id.encode("utf-8"))
def test_create_email_persisted(client: FlaskClient) -> None: # GIVEN email = VALID_EMAIL # WHEN create_user_successfully(client, email=email) # THEN user = get_user_by_email(email) assert user.email == email
def test_create_rsp_contains_topic(client: FlaskClient) -> None: # GIVEN email = VALID_EMAIL # WHEN rsp = create_user_successfully(client) # THEN user = get_user_by_email(email) expected_topic = f"user.{user.hashed_id}.message" assert expected_topic == rsp.json["topic"]
def test_create_hashed_password_persisted(client: FlaskClient) -> None: # GIVEN email = VALID_EMAIL password = VALID_PASSWORD # WHEN create_user_successfully(client, email=email, password=password) # THEN user = get_user_by_email(email) assert bcrypt.checkpw(password.encode("utf-8"), user.password)
def test_create_rmq_topic_permission_set(client: FlaskClient) -> None: # GIVEN email = random_valid_email() # WHEN create_user_successfully(client, email=email) # THEN user = get_user_by_email(email) expected_write = r"^.*%s.*$" % re.escape(user.hashed_id) expected_read = r"^.*%s.*$" % re.escape(user.hashed_id) print(expected_write) permissions = RabbitMQ().get_topic_permissions(email) assert len(permissions) == 1 permission = permissions[0] assert permission["user"] == email assert permission["write"] == expected_write assert permission["read"] == expected_read