Skip to content

Commit a7e78df

Browse files
committed
fixup! Apply suggestions from code review
1 parent d9587d7 commit a7e78df

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

src/test/java/com/siemens/pki/cmpclientcomponent/test/CmpClientTestcaseBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected static CmpMessageInterface getPasswordBasedUpstreamconfigurationWithou
120120

121121
@Override
122122
public VerificationContext getInputVerification() {
123-
return null;
123+
return new PasswordValidationCredentials(protection.getSharedSecret());
124124
}
125125

126126
@Override

src/test/java/com/siemens/pki/cmpclientcomponent/test/TestPasswordBasedIrWithoutResponseValidation.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import com.siemens.pki.cmpclientcomponent.main.CmpClient.EnrollmentResult;
2323
import com.siemens.pki.cmpracomponent.configuration.Configuration;
24+
import com.siemens.pki.cmpracomponent.msgvalidation.CmpValidationException;
2425
import com.siemens.pki.cmpracomponent.test.framework.ConfigurationFactory;
2526
import com.siemens.pki.cmpracomponent.test.framework.SharedSecret;
2627
import com.siemens.pki.cmpracomponent.test.framework.TestUtils;
@@ -34,21 +35,29 @@ public class TestPasswordBasedIrWithoutResponseValidation extends EnrollmentTest
3435
@Before
3536
public void setUp() throws Exception {
3637
final Configuration config =
37-
ConfigurationFactory.buildPasswordbasedDownstreamConfigurationWithoutResponseValidation();
38+
ConfigurationFactory.buildPasswordbasedDownstreamConfigurationWithoutResponseProtection();
3839
launchCmpCaAndRa(config);
3940
}
4041

41-
@Test
42-
public void testIrWithoutResponseValidation() throws Exception {
43-
final EnrollmentResult ret = getPasswordBasedCmpClientWithoutResponseValidation(
44-
"theCertProfileForOnlineEnrollmentWithoutResponseValidation",
45-
getClientContext(
46-
PKIBody.TYPE_CERT_REQ,
47-
ConfigurationFactory.getKeyGenerator().generateKeyPair(),
48-
null),
49-
new SharedSecret("PASSWORDBASEDMAC", TestUtils.PASSWORD),
50-
null)
51-
.invokeEnrollment();
52-
assertNotNull(ret);
42+
/**
43+
*
44+
* @throws Throwable if unprotected response is received
45+
*/
46+
@Test(expected = CmpValidationException.class)
47+
public void testIrWithoutResponseValidation() throws Throwable {
48+
try {
49+
final EnrollmentResult ret = getPasswordBasedCmpClientWithoutResponseValidation(
50+
"theCertProfileForOnlineEnrollmentWithoutResponseValidation",
51+
getClientContext(
52+
PKIBody.TYPE_CERT_REQ,
53+
ConfigurationFactory.getKeyGenerator().generateKeyPair(),
54+
null),
55+
new SharedSecret("PASSWORDBASEDMAC", TestUtils.PASSWORD),
56+
null)
57+
.invokeEnrollment();
58+
assertNotNull(ret);
59+
} catch (RuntimeException ex) {
60+
throw ex.getCause();
61+
}
5362
}
5463
}

src/test/java/com/siemens/pki/cmpracomponent/test/framework/ConfigurationFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static Configuration buildPasswordbasedDownstreamConfiguration() throws E
101101
enrollmentTrust);
102102
}
103103

104-
public static Configuration buildPasswordbasedDownstreamConfigurationWithoutResponseValidation() throws Exception {
104+
public static Configuration buildPasswordbasedDownstreamConfigurationWithoutResponseProtection() throws Exception {
105105

106106
final VerificationContext downstreamTrust = new PasswordValidationCredentials(TestUtils.PASSWORD);
107107

0 commit comments

Comments
 (0)