Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relaxed account regex per ENG-83 #302

Merged
merged 2 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion servo/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
]


ORGANIZATION_REGEX = r"(([\da-zA-Z])([_\w-]{,62})\.){,127}(([\da-zA-Z])[_\w-]{,61})?([\da-zA-Z]\.((xn\-\-[a-zA-Z\d]+)|([a-zA-Z\d]{2,})))"
ORGANIZATION_REGEX = r"(?!-)([A-Za-z0-9-.]+){5,50}"
NAME_REGEX = r"[a-zA-Z\_\-\.0-9]{1,64}"
OPTIMIZER_ID_REGEX = f"^{ORGANIZATION_REGEX}/{NAME_REGEX}$"

Expand Down
6 changes: 3 additions & 3 deletions tests/connector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def test_organization_valid(self) -> None:

def test_organization_invalid(self) -> None:
with pytest.raises(ValidationError) as e:
Optimizer(id="invalid/my-app", token="123456")
Optimizer(id="inval/id/my-app", token="123456")
assert "1 validation error for Optimizer" in str(e.value)
assert e.value.errors()[0]["loc"] == ("id",)
assert (
e.value.errors()[0]["msg"]
== r'string does not match regex "^(([\da-zA-Z])([_\w-]{,62})\.){,127}(([\da-zA-Z])[_\w-]{,61})?([\da-zA-Z]\.((xn\-\-[a-zA-Z\d]+)|([a-zA-Z\d]{2,})))/[a-zA-Z\_\-\.0-9]{1,64}$"'
== r'string does not match regex "^(?!-)([A-Za-z0-9-.]+){5,50}/[a-zA-Z\_\-\.0-9]{1,64}$"'
)

def test_name_valid(self) -> None:
Expand All @@ -50,7 +50,7 @@ def test_name_invalid(self) -> None:
assert e.value.errors()[0]["loc"] == ("id",)
assert (
e.value.errors()[0]["msg"]
== r'string does not match regex "^(([\da-zA-Z])([_\w-]{,62})\.){,127}(([\da-zA-Z])[_\w-]{,61})?([\da-zA-Z]\.((xn\-\-[a-zA-Z\d]+)|([a-zA-Z\d]{2,})))/[a-zA-Z\_\-\.0-9]{1,64}$"'
== r'string does not match regex "^(?!-)([A-Za-z0-9-.]+){5,50}/[a-zA-Z\_\-\.0-9]{1,64}$"'
)

def test_token_validation(self) -> None:
Expand Down
3 changes: 1 addition & 2 deletions tests/servo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,7 @@ async def test_aliased_connectors_produce_schema(self, servo_yaml: Path, mocker)
'title': 'Id',
'env_names': ['id'],
'pattern': (
'^(([\\da-zA-Z])([_\\w-]{,62})\\.){,127}(([\\da-zA-Z])[_\\w-]{,61})?([\\da-zA-Z]\\.((xn\\-\\-[a-zA-'
'Z\\d]+)|([a-zA-Z\\d]{2,})))/[a-zA-Z\\_\\-\\.0-9]{1,64}$'
'^(?!-)([A-Za-z0-9-.]+){5,50}/[a-zA-Z\\_\\-\\.0-9]{1,64}$'
),
'type': 'string',
},
Expand Down