-
Notifications
You must be signed in to change notification settings - Fork 188
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
Forbid more characters from request/deploy IDs #1407
Conversation
In an effort to prevent attempting to create docker containers with names that docker will refuse, this forbids more characters from being used in request/deploy IDs. This is actually more of a whitelist approach than a blacklist approach; it explicitly says the characters that can be used and forbids anything else.
@@ -0,0 +1,63 @@ | |||
package com.hubspot.singularity.data; | |||
|
|||
import static org.mockito.Mockito.*; |
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.
We generally try to stay away from any import *
if we can. Can probably tune your IDE settings for this
@Rule | ||
public ExpectedException expectedException = ExpectedException.none(); | ||
|
||
public static class TestModule extends JukitoModule { |
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.
We actually have a class set up that handles most of this setup already. If you just add these tests in the ValidatorTest
class (feel free to rename to SingularityValidatorTest
for consistency), that class already has all of the guice bits taken care of and you can use the already injected SingularityValidator
. Saves us from adding the mockito dep for just this class as well ;)
Move the code from the validator test class that I had created into a the existing validator test class. This let me get rid of the dependencies that I had added as a part of testing my code.
public void itForbidsBracketCharactersInDeployIds() throws Exception { | ||
final String badDeployId = "deployKey[["; | ||
|
||
SingularityDeploy singularityDeploy = new SingularityDeploy(badDeployId, badDeployId, |
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.
There are SingularityDeployBuilder
and SingularityRequestBuilder
methods for this so that you don't need to use the giant constructor. For example you could do:
SingularityDeploy.newBuilder("requestId", "deployId")
Fix that up and I think this PR is all set 👍
Use builders to create the Singularity{Request,Deploy} instances that were needed for testing. This lets the contructors and all of their `Optional.<>absent()` arguments be elided, which makes the whole think much, much easier to read. Thanks to Stephen for the fix.
LGTM |
In an effort to prevent attempting to create docker containers
with names that docker will refuse, this forbids more characters
from being used in request/deploy IDs. This is actually more of a
whitelist approach than a blacklist approach; it explicitly
says the characters that can be used and forbids anything else.
Closes #1406
/cc @ssalinas