Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ credentials:
- gitlabPersonalAccessToken:
scope: SYSTEM
id: "i<3GitLab"
token: "XfsqZvVtAx5YCph5bq3r" # gitlab personal access token
token: "glpat-XfsqZvVtAx5YCph5bq3r" # gitlab personal access token

unclassified:
gitLabServers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Secret getToken() {
@Symbol("gitlabPersonalAccessToken")
public static class DescriptorImpl extends CredentialsDescriptor {

private static final int GITLAB_ACCESS_TOKEN_LENGTH = 20;
private static final int GITLAB_ACCESS_TOKEN_MINIMAL_LENGTH = 20;

/**
* {@inheritDoc}
Expand All @@ -87,11 +87,11 @@ public String getDisplayName() {
public FormValidation doCheckToken(@QueryParameter String value) {
Secret secret = Secret.fromString(value);
if (StringUtils.equals(value, secret.getPlainText())) {
if (value.length() != GITLAB_ACCESS_TOKEN_LENGTH) {
if (value.length() < GITLAB_ACCESS_TOKEN_MINIMAL_LENGTH) {
return FormValidation
.error(Messages.PersonalAccessTokenImpl_tokenWrongLength());
}
} else if (secret.getPlainText().length() != GITLAB_ACCESS_TOKEN_LENGTH) {
} else if (secret.getPlainText().length() < GITLAB_ACCESS_TOKEN_MINIMAL_LENGTH) {
return FormValidation.error(Messages.PersonalAccessTokenImpl_tokenWrongLength());
}
return FormValidation.ok();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PersonalAccessTokenImpl.displayName=GitLab Personal Access Token
PersonalAccessTokenImpl.tokenRequired=Token required
PersonalAccessTokenImpl.tokenWrongLength=Token should be 20 characters long
PersonalAccessTokenImpl.tokenWrongLength=Token should be at least 20 characters long
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void should_support_configuration_as_code() {
);
assertThat(credentials, hasSize(1));
final PersonalAccessTokenImpl credential = credentials.get(0);
assertThat(credential.getToken().getPlainText(), is("XfsqZvVtAx5YCph5bq3r"));
assertThat(credential.getToken().getEncryptedValue(), is(not("XfsqZvVtAx5YCph5bq3r")));
assertThat(credential.getToken().getPlainText(), is("glpat-XfsqZvVtAx5YCph5bq3r"));
assertThat(credential.getToken().getEncryptedValue(), is(not("glpat-XfsqZvVtAx5YCph5bq3r")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ credentials:
- gitlabPersonalAccessToken:
scope: SYSTEM
id: "i<3GitLab"
token: "XfsqZvVtAx5YCph5bq3r"
token: "glpat-XfsqZvVtAx5YCph5bq3r"

unclassified:
gitLabServers:
Expand Down