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

Relax the service name validation to allow one char names #2043

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public static void validateServiceId(String serviceId) {
messages.add(String.format("Must not case-insensitively end with `%s`", suffix));
});

if (serviceId.length() < 2 || serviceId.length() > 50) {
messages.add("Must be between 2 and 50 characters long.");
if (serviceId.isEmpty() || serviceId.length() > 50) {
messages.add("Must be between 1 and 50 characters long.");
}

if (!messages.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ public void noTrailingWhitespace() {
@Test
public void doesNotAllowShortIds() {
IllegalArgumentException thrown = Assertions.assertThrows(IllegalArgumentException.class, () ->
SdkServiceIdValidator.validateServiceId("F"));
SdkServiceIdValidator.validateServiceId(""));

assertThat(thrown.getMessage(), containsString("2 and 50"));
assertThat(thrown.getMessage(), containsString("1 and 50"));
}

@Test
public void doesNotAllowLongIds() {
IllegalArgumentException thrown = Assertions.assertThrows(IllegalArgumentException.class, () ->
SdkServiceIdValidator.validateServiceId("Foobarbazqux Foobarbazqux Foobarbazqux Foobarbazqux"));

assertThat(thrown.getMessage(), containsString("2 and 50"));
assertThat(thrown.getMessage(), containsString("1 and 50"));
}
}