Skip to content

Commit

Permalink
Don't allow empty strings for Service Account fields (#2087)
Browse files Browse the repository at this point in the history
  • Loading branch information
kruai authored Nov 22, 2024
1 parent 94d4e93 commit 72341b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/auth/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class SystemIdentitySchema(IdentityBaseSchema):


class ServiceAccountInfoIdentitySchema(IdentityBaseSchema):
client_id = m.fields.Str(required=True)
username = m.fields.Str(required=True)
client_id = m.fields.Str(required=True, validate=m.validate.Length(min=1))
username = m.fields.Str(required=True, validate=m.validate.Length(min=1))


class ServiceAccountIdentitySchema(IdentityBaseSchema):
Expand Down
10 changes: 9 additions & 1 deletion tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,15 @@ def test_invalid_system_obj(self):

def test_invalid_service_account_obj(self):
test_identity = deepcopy(SERVICE_ACCOUNT_IDENTITY)
service_account_objects = [None, ""]
service_account_objects = [
None,
"",
{
"client_id": SERVICE_ACCOUNT_IDENTITY["service_account"]["client_id"],
"username": "",
},
{"client_id": "", "username": SERVICE_ACCOUNT_IDENTITY["service_account"]["username"]},
]
for service_account_object in service_account_objects:
with self.subTest(service_account_object=service_account_object):
test_identity["service_account"] = service_account_object
Expand Down

0 comments on commit 72341b4

Please sign in to comment.