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

🚀 Adapt to changes from credentials regarding password length in FIPS mode #545

Merged
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
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1378.v81ef4269d764</version>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we providing the version here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just need to force version containing this change jenkinsci/jenkins-test-harness#829

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I follow, if you want that change, then change the property jenkins-test-harness.version?

do you mean that you want a version containing jenkinsci/credentials-plugin#558 instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup sounds like a typo

</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/hudson/plugins/emailext/MailAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,19 @@
if (StringUtils.isBlank(credentialsId)) {
// If we couldn't find any existing credentials,
// create new credentials with the principal and secret and use it.
final StandardUsernamePasswordCredentials newCredentials = new UsernamePasswordCredentialsImpl(
CredentialsScope.GLOBAL,
null,
"Migrated from email-ext username/password",
smtpUsername,
smtpPassword.getPlainText());
final StandardUsernamePasswordCredentials newCredentials;
try {
newCredentials = new UsernamePasswordCredentialsImpl(
CredentialsScope.GLOBAL,
null,
"Migrated from email-ext username/password",
smtpUsername,
smtpPassword.getPlainText());
} catch (Descriptor.FormException e) {
// safe to ignore as too short password should happen only in FIPS mode
// and migrating from no FIPS to FIPS is not supported, but only fresh start
throw new RuntimeException(e);

Check warning on line 323 in src/main/java/hudson/plugins/emailext/MailAccount.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 320-323 are not covered by tests
slide marked this conversation as resolved.
Show resolved Hide resolved
}
SystemCredentialsProvider.getInstance().getCredentials().add(newCredentials);
credentialsId = newCredentials.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ public void testIsValidAuthConfigAndTLS() {
}

@Test
public void testFormValidationForInsecureAuth() {
public void testFormValidationForInsecureAuth() throws Exception {
final String validCredentialId = "valid-id";
SystemCredentialsProvider.getInstance()
.getCredentials()
.add(new UsernamePasswordCredentialsImpl(
CredentialsScope.GLOBAL, validCredentialId, "description", "username", "password"));
CredentialsScope.GLOBAL,
validCredentialId,
"description",
"username",
"password-must-be-longer-for-fips"));

MailAccountDescriptor mad = (MailAccountDescriptor) Jenkins.get().getDescriptor(MailAccount.class);

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/hudson/plugins/emailext/MailAccountTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void testUpgradeDuringCredentialsGetter() {
}

@Test
public void testFormValidationForInsecureAuth() {
public void testFormValidationForInsecureAuth() throws Exception {
final String validCredentialId = "valid-id";
SystemCredentialsProvider.getInstance()
.getCredentials()
Expand Down