Skip to content

Commit 1da694e

Browse files
committed
Remove TestSaml2SigningCredentials
Since TestSaml2X509Credentials is where tests get Saml2X509Credentials, there is no reason for TestSaml2SigningCredentials. Issue gh-8404
1 parent ab77289 commit 1da694e

File tree

8 files changed

+23
-141
lines changed

8 files changed

+23
-141
lines changed
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.security.saml2.provider.service.authentication;
17+
package org.springframework.security.saml2.credentials;
1818

1919
import java.io.ByteArrayInputStream;
2020
import java.security.KeyException;
@@ -26,36 +26,35 @@
2626
import org.opensaml.security.crypto.KeySupport;
2727

2828
import org.springframework.security.saml2.Saml2Exception;
29-
import org.springframework.security.saml2.credentials.Saml2X509Credential;
3029

3130
import static java.nio.charset.StandardCharsets.UTF_8;
3231
import static org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType.DECRYPTION;
3332
import static org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType.ENCRYPTION;
3433
import static org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType.SIGNING;
3534
import static org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType.VERIFICATION;
3635

37-
final class TestSaml2X509Credentials {
38-
static Saml2X509Credential assertingPartySigningCredential() {
36+
public final class TestSaml2X509Credentials {
37+
public static Saml2X509Credential assertingPartySigningCredential() {
3938
return new Saml2X509Credential(idpPrivateKey(), idpCertificate(), SIGNING);
4039
}
4140

42-
static Saml2X509Credential assertingPartyEncryptingCredential() {
41+
public static Saml2X509Credential assertingPartyEncryptingCredential() {
4342
return new Saml2X509Credential(spCertificate(), ENCRYPTION);
4443
}
4544

46-
static Saml2X509Credential assertingPartyPrivateCredential() {
45+
public static Saml2X509Credential assertingPartyPrivateCredential() {
4746
return new Saml2X509Credential(idpPrivateKey(), idpCertificate(), SIGNING, DECRYPTION);
4847
}
4948

50-
static Saml2X509Credential relyingPartyVerifyingCredential() {
49+
public static Saml2X509Credential relyingPartyVerifyingCredential() {
5150
return new Saml2X509Credential(idpCertificate(), VERIFICATION);
5251
}
5352

54-
static Saml2X509Credential relyingPartySigningCredential() {
53+
public static Saml2X509Credential relyingPartySigningCredential() {
5554
return new Saml2X509Credential(spPrivateKey(), spCertificate(), SIGNING);
5655
}
5756

58-
static Saml2X509Credential relyingPartyDecryptingCredential() {
57+
public static Saml2X509Credential relyingPartyDecryptingCredential() {
5958
return new Saml2X509Credential(spPrivateKey(), spCertificate(), DECRYPTION);
6059
}
6160

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/authentication/OpenSamlAuthenticationProviderTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
import static org.springframework.security.saml2.provider.service.authentication.TestOpenSamlObjects.encrypted;
4343
import static org.springframework.security.saml2.provider.service.authentication.TestOpenSamlObjects.response;
4444
import static org.springframework.security.saml2.provider.service.authentication.TestOpenSamlObjects.signed;
45-
import static org.springframework.security.saml2.provider.service.authentication.TestSaml2X509Credentials.assertingPartyEncryptingCredential;
46-
import static org.springframework.security.saml2.provider.service.authentication.TestSaml2X509Credentials.assertingPartyPrivateCredential;
47-
import static org.springframework.security.saml2.provider.service.authentication.TestSaml2X509Credentials.assertingPartySigningCredential;
48-
import static org.springframework.security.saml2.provider.service.authentication.TestSaml2X509Credentials.relyingPartyDecryptingCredential;
49-
import static org.springframework.security.saml2.provider.service.authentication.TestSaml2X509Credentials.relyingPartyVerifyingCredential;
45+
import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.assertingPartyEncryptingCredential;
46+
import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.assertingPartyPrivateCredential;
47+
import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.assertingPartySigningCredential;
48+
import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.relyingPartyDecryptingCredential;
49+
import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.relyingPartyVerifyingCredential;
5050
import static org.springframework.test.util.AssertionErrors.assertTrue;
5151
import static org.springframework.util.StringUtils.hasText;
5252

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/authentication/OpenSamlAuthenticationRequestFactoryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import static org.assertj.core.api.Assertions.assertThat;
3232
import static org.hamcrest.CoreMatchers.containsString;
3333
import static org.springframework.security.saml2.provider.service.authentication.Saml2Utils.samlDecode;
34-
import static org.springframework.security.saml2.provider.service.authentication.TestSaml2X509Credentials.relyingPartySigningCredential;
34+
import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.relyingPartySigningCredential;
3535
import static org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration.withRelyingPartyRegistration;
3636
import static org.springframework.security.saml2.provider.service.registration.Saml2MessageBinding.POST;
3737
import static org.springframework.security.saml2.provider.service.registration.Saml2MessageBinding.REDIRECT;

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/authentication/OpenSamlImplementationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import static org.assertj.core.api.Assertions.assertThat;
3131
import static org.opensaml.xmlsec.signature.support.SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256;
3232
import static org.springframework.security.saml2.provider.service.authentication.TestOpenSamlObjects.getSigningCredential;
33-
import static org.springframework.security.saml2.provider.service.authentication.TestSaml2X509Credentials.assertingPartySigningCredential;
34-
import static org.springframework.security.saml2.provider.service.authentication.TestSaml2X509Credentials.relyingPartyVerifyingCredential;
33+
import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.assertingPartySigningCredential;
34+
import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.relyingPartyVerifyingCredential;
3535

3636
public class OpenSamlImplementationTests {
3737

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/authentication/Saml2AuthenticationRequestFactoryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import static org.assertj.core.api.Assertions.assertThat;
2626
import static org.springframework.security.saml2.provider.service.authentication.Saml2Utils.samlDecode;
2727
import static org.springframework.security.saml2.provider.service.authentication.Saml2Utils.samlInflate;
28-
import static org.springframework.security.saml2.provider.service.authentication.TestSaml2X509Credentials.relyingPartySigningCredential;
28+
import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.relyingPartySigningCredential;
2929

3030
/**
3131
* Tests for {@link Saml2AuthenticationRequestFactory} default interface methods

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/servlet/filter/Saml2WebSsoAuthenticationRequestFilterTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
import static org.mockito.Mockito.verify;
4141
import static org.mockito.Mockito.verifyNoInteractions;
4242
import static org.mockito.Mockito.when;
43+
import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.assertingPartyPrivateCredential;
4344
import static org.springframework.security.saml2.provider.service.registration.Saml2MessageBinding.POST;
44-
import static org.springframework.security.saml2.provider.service.servlet.filter.TestSaml2SigningCredentials.signingCredential;
4545

4646
public class Saml2WebSsoAuthenticationRequestFilterTests {
4747

@@ -68,7 +68,7 @@ public void setup() {
6868
.providerDetails(c -> c.entityId("idp-entity-id"))
6969
.providerDetails(c -> c.webSsoUrl(IDP_SSO_URL))
7070
.assertionConsumerServiceUrlTemplate("template")
71-
.credentials(c -> c.add(signingCredential()));
71+
.credentials(c -> c.add(assertingPartyPrivateCredential()));
7272
}
7373

7474
@Test

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/servlet/filter/TestSaml2SigningCredentials.java

Lines changed: 0 additions & 118 deletions
This file was deleted.

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/web/DefaultSaml2AuthenticationRequestContextResolverTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818

1919
import org.junit.Before;
2020
import org.junit.Test;
21+
2122
import org.springframework.mock.web.MockHttpServletRequest;
2223
import org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationRequestContext;
2324
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration;
2425

25-
import static org.springframework.security.saml2.provider.service.servlet.filter.TestSaml2SigningCredentials.signingCredential;
2626
import static org.assertj.core.api.Assertions.assertThat;
2727
import static org.assertj.core.api.Assertions.assertThatCode;
28+
import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.relyingPartyVerifyingCredential;
2829

2930
/**
3031
* Tests for {@link DefaultSaml2AuthenticationRequestContextResolver}
@@ -54,7 +55,7 @@ public void setup() {
5455
.providerDetails(c -> c.entityId(ASSERTING_PARTY_ENTITY_ID))
5556
.providerDetails(c -> c.webSsoUrl(ASSERTING_PARTY_SSO_URL))
5657
.assertionConsumerServiceUrlTemplate(RELYING_PARTY_SSO_URL)
57-
.credentials(c -> c.add(signingCredential()));
58+
.credentials(c -> c.add(relyingPartyVerifyingCredential()));
5859
}
5960

6061
@Test

0 commit comments

Comments
 (0)