Skip to content

Commit

Permalink
Expect exact number of columns
Browse files Browse the repository at this point in the history
  • Loading branch information
JimMadge committed Aug 7, 2023
1 parent c8e9b7a commit 9303c35
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def list(self, sre_name: str | None = None) -> Sequence[ResearchUser]: # noqa:
expected_columns = 6
for line in output.split("\n"):
tokens = line.split(";")
if len(tokens) >= expected_columns:
if (n_tokens := len(tokens)) == expected_columns:
users.append(
ResearchUser(
email_address=tokens[4],
Expand All @@ -106,8 +106,8 @@ def list(self, sre_name: str | None = None) -> Sequence[ResearchUser]: # noqa:
)
else:
msg = (
"Fewer than expected number of fields returned for Active Directory"
f" user: {tokens}"
"Unexpected number of fields returned for Active Directory user.\n"
f"Expected {expected_columns}, got {n_tokens}"
)
raise DataSafeHavenActiveDirectoryError(msg)
return users
Expand Down

0 comments on commit 9303c35

Please sign in to comment.