-
Notifications
You must be signed in to change notification settings - Fork 541
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
Add check for image name length to not exceed 255
#2555
Changes from all commits
f52dfa3
f4d8573
bceee52
f4a0977
1593395
298e579
e91f186
325723f
ad8f7a5
21ca153
9e76a49
6d6aa4a
d733469
7249365
d07beb7
1b17182
b28639c
ccfb414
30c2ab6
95a7bbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.kit.config.image; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
|
@@ -124,6 +124,23 @@ private void verifyData(Object[] data) { | |
void testIllegalFormat() { | ||
assertThrows(IllegalArgumentException.class, () -> new ImageName("")); | ||
} | ||
@Test | ||
void shouldThrowExceptionOnTooLongImageName() { | ||
// New test for too long repository name | ||
String tooLongName = generateTooLongImageName(); | ||
assertThatIllegalArgumentException() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I meant to add a new test; not modify existing test. Could you please move this code block into a separate test? @Test
void shouldThrowExceptionOnTooLongImageName() {
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hii @rohanKanojia did all the changes you told me do, but getting a build failure [INFO] BUILD FAILURE is it due to my changes? or can you suggest how can i fix this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
test added by me is passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Devashishbasu : This failure seems unrelated to your changes. Probably it's a flaky test that needs to be fixed. Could you please try pushing again and see if you see the issue again? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hi @rohanKanojia i've pushed the code again and seeing the same issue again...it is the same issue which you have opened #2576 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hii @rohanKanojia ...still the same issue persists |
||
.as("Too long image name should fail") | ||
.isThrownBy(() -> new ImageName(tooLongName)) | ||
.withMessageContaining("Repository name must not be more than 255 characters"); | ||
|
||
} | ||
|
||
private String generateTooLongImageName() { | ||
char repeatedChar = 'a'; | ||
int maxLength = 255 + 1; | ||
String tooLongName = StringUtils.repeat(repeatedChar, maxLength); | ||
return tooLongName; | ||
} | ||
|
||
@Test | ||
void namesUsedByDockerTests() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add one more test in ImageNameTest for verifying exception with this exact message is thrown when too long image name is provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya sure