♻️(schema) stop forcing users to be uuid (represented by a sub)
The list of users allowed to access a document is a sub and is not guaranteed to be a UUID.
This commit is contained in:
committed by
Florian Fabre
parent
0bceab930c
commit
e463b3daba
@@ -19,7 +19,7 @@ class DocumentSchemaFactory(factory.DictFactory):
|
||||
indexation for testing and development purposes.
|
||||
"""
|
||||
|
||||
id = factory.LazyFunction(uuid4)
|
||||
id = factory.LazyFunction(lambda: str(uuid4()))
|
||||
title = factory.Sequence(lambda n: f"Test title {n!s}")
|
||||
path = factory.Sequence(lambda n: f"000{n}")
|
||||
content = factory.Sequence(lambda n: f"Test content {n!s}")
|
||||
@@ -27,7 +27,7 @@ class DocumentSchemaFactory(factory.DictFactory):
|
||||
lambda: fake.date_time_this_decade(tzinfo=timezone.get_current_timezone())
|
||||
)
|
||||
size = factory.LazyFunction(lambda: fake.random_int(min=0, max=1024**2))
|
||||
users = factory.LazyFunction(lambda: [uuid4() for _ in range(3)])
|
||||
users = factory.LazyFunction(lambda: [str(uuid4()) for _ in range(3)])
|
||||
groups = factory.LazyFunction(lambda: [slugify(fake.word()) for _ in range(3)])
|
||||
reach = factory.Iterator(list(enums.ReachEnum))
|
||||
depth = 1
|
||||
|
||||
@@ -31,7 +31,7 @@ class DocumentSchema(BaseModel):
|
||||
created_at: AwareDatetime
|
||||
updated_at: AwareDatetime
|
||||
size: Annotated[int, Field(ge=0, le=100 * 1024**3)] # File size limited to 100GB
|
||||
users: List[UUID4] = Field(default_factory=list)
|
||||
users: List[Annotated[str, Field(max_length=50)]] = Field(default_factory=list)
|
||||
groups: List[Annotated[str, Field(pattern=r"^[a-z0-9]+(?:-[a-z0-9]+)*$")]] = Field(
|
||||
default_factory=list
|
||||
)
|
||||
|
||||
@@ -140,12 +140,9 @@ def test_api_documents_index_bulk_success():
|
||||
),
|
||||
(
|
||||
"users",
|
||||
["33052c8b-3181-4420-aede-f8396fc0f9az"], # invalid UUID b/c contains a z
|
||||
"uuid_parsing",
|
||||
(
|
||||
"Input should be a valid UUID, invalid character: expected an optional "
|
||||
"prefix of `urn:uuid:` followed by [0-9a-fA-F-], found `z` at 36"
|
||||
),
|
||||
["a" * 51],
|
||||
"string_too_long",
|
||||
"String should have at most 50 characters",
|
||||
),
|
||||
(
|
||||
"groups",
|
||||
|
||||
@@ -137,12 +137,9 @@ def test_api_documents_index_single_success():
|
||||
),
|
||||
(
|
||||
"users",
|
||||
["33052c8b-3181-4420-aede-f8396fc0f9az"], # invalid UUID b/c contains a z*
|
||||
"uuid_parsing",
|
||||
(
|
||||
"Input should be a valid UUID, invalid character: expected an optional "
|
||||
"prefix of `urn:uuid:` followed by [0-9a-fA-F-], found `z` at 36"
|
||||
),
|
||||
["a" * 51],
|
||||
"string_too_long",
|
||||
"String should have at most 50 characters",
|
||||
),
|
||||
(
|
||||
"groups",
|
||||
|
||||
Reference in New Issue
Block a user