auth service up running
This commit is contained in:
@@ -36,10 +36,9 @@ CrudCollection.http_exception = HTTPException
|
||||
new_person_find_or_create = People.find_or_create(**person_dict)
|
||||
new_person_find_or_create.save_via_metadata()
|
||||
|
||||
print('meta_data', new_person_find_or_create.meta_data)
|
||||
print('new_person_find_or_create', new_person_find_or_create)
|
||||
print("meta_data", new_person_find_or_create.meta_data)
|
||||
print("new_person_find_or_create", new_person_find_or_create)
|
||||
|
||||
quit()
|
||||
new_user_find_or_create = Users.find_or_create(**user_dict)
|
||||
new_user_find_or_abort = Users.find_or_abort(**user_dict)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ def create_test_occupant_token(
|
||||
person_id: int = 1,
|
||||
person_uu_id: str = "test-person",
|
||||
credentials: Optional[Dict[str, Any]] = None,
|
||||
available_occupants: Optional[Dict[str, Any]] = None
|
||||
available_occupants: Optional[Dict[str, Any]] = None,
|
||||
) -> OccupantTokenObject:
|
||||
"""Create a test occupant token object"""
|
||||
return OccupantTokenObject(
|
||||
@@ -32,7 +32,7 @@ def create_test_employee_token(
|
||||
person_id: int = 1,
|
||||
person_uu_id: str = "test-person",
|
||||
credentials: Optional[Dict[str, Any]] = None,
|
||||
selected_company: Optional[Dict[str, Any]] = None
|
||||
selected_company: Optional[Dict[str, Any]] = None,
|
||||
) -> EmployeeTokenObject:
|
||||
"""Create a test employee token object"""
|
||||
return EmployeeTokenObject(
|
||||
@@ -50,5 +50,6 @@ def create_test_employee_token(
|
||||
|
||||
class MockRequest:
|
||||
"""Mock request object for testing"""
|
||||
|
||||
def __init__(self, headers: Optional[Dict[str, str]] = None):
|
||||
self.headers = headers or {}
|
||||
|
||||
@@ -35,9 +35,7 @@ def test_save_object_to_redis_success():
|
||||
|
||||
# Test save
|
||||
result = AccessObjectActions.save_object_to_redis(
|
||||
access_token=access_token,
|
||||
model_object=model_object,
|
||||
expiry_minutes=1
|
||||
access_token=access_token, model_object=model_object, expiry_minutes=1
|
||||
)
|
||||
assert result is True
|
||||
|
||||
@@ -69,7 +67,7 @@ def test_save_object_to_redis_expiry():
|
||||
AccessObjectActions.save_object_to_redis(
|
||||
access_token=access_token,
|
||||
model_object=model_object,
|
||||
expiry_minutes=2/60 # 2 seconds
|
||||
expiry_minutes=2 / 60, # 2 seconds
|
||||
)
|
||||
|
||||
# Verify token exists
|
||||
@@ -86,13 +84,15 @@ def test_save_object_to_redis_expiry():
|
||||
RedisActions.get_object_via_access_key(
|
||||
MockRequest(headers={Auth.ACCESS_TOKEN_TAG: access_token})
|
||||
)
|
||||
assert any(msg in str(exc_info.value) for msg in ["Token expired", "Invalid credentials"])
|
||||
assert any(
|
||||
msg in str(exc_info.value) for msg in ["Token expired", "Invalid credentials"]
|
||||
)
|
||||
|
||||
|
||||
def test_get_object_via_user_uu_id():
|
||||
"""Test retrieving all tokens for a user"""
|
||||
user_id = "test-uuid-3"
|
||||
|
||||
|
||||
# Create multiple tokens for same user
|
||||
tokens = []
|
||||
for i in range(3):
|
||||
@@ -114,7 +114,7 @@ def test_get_object_via_user_uu_id():
|
||||
# Get all tokens
|
||||
user_tokens = AccessObjectActions.get_object_via_user_uu_id(user_id)
|
||||
assert len(user_tokens) == 3
|
||||
|
||||
|
||||
# Verify each token
|
||||
for token in tokens:
|
||||
found = False
|
||||
@@ -167,7 +167,7 @@ def test_timezone_handling():
|
||||
token_data = RedisActions.get_object_via_access_key(
|
||||
MockRequest(headers={Auth.ACCESS_TOKEN_TAG: access_token})
|
||||
)
|
||||
|
||||
|
||||
# Verify expiry time is in future
|
||||
assert system_arrow.from_timestamp(token_data.expires_at) > system_arrow.now()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user