Skip to content

Commit

Permalink
Fix cloud backup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
themylogin committed Nov 26, 2024
1 parent 3b878a6 commit b475c10
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/api/base/types/base/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __get_pydantic_core_schema__(
LongString = Annotated[
LongStringWrapper,
BeforeValidator(LongStringWrapper),
PlainSerializer(lambda x: undefined if x == undefined else x.value),
PlainSerializer(lambda x: x.value if isinstance(x, LongStringWrapper) else x),
]

NonEmptyString = Annotated[str, Field(min_length=1)]
Expand Down
4 changes: 2 additions & 2 deletions src/middlewared/middlewared/api/v25_04_0/cloud_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class CloudBackupCreate(BaseModel):
pre_script: LongString = ""
post_script: LongString = ""
snapshot: bool = False
include: list[NonEmptyString]
exclude: list[NonEmptyString]
include: list[NonEmptyString] = []
exclude: list[NonEmptyString] = []
args: LongString = ""
enabled: bool = True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ class SecretLongStringMethodArgs(BaseModel):

def test_secret_long_string():
assert accept_params(SecretLongStringMethodArgs, ["test"]) == ["test"]


class LongStringDefaultMethodArgs(BaseModel):
str: LongString = ""


def test_long_string_default():
assert accept_params(LongStringDefaultMethodArgs, []) == [""]
2 changes: 1 addition & 1 deletion tests/api2/test_account_privilege_role_private_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def vmware():
("acme.dns.authenticator", dns_authenticator, {}, ["attributes"]),
("certificate", 1, {}, ["privatekey", "issuer"]),
("certificateauthority", certificateauthority, {}, ["privatekey", "issuer"]),
("cloud_backup", cloudbackup, {}, ["credentials.provider", "password"]),
("cloud_backup", cloudbackup, {}, ["credentials.provider.pass", "password"]),
("cloudsync.credentials", cloudsync_credential, {}, ["provider.pass"]),
("cloudsync", cloudsync, {}, ["credentials.provider", "encryption_password"]),
("disk", disk, {"extra": {"passwords": True}}, ["passwd"]),
Expand Down

0 comments on commit b475c10

Please sign in to comment.