Skip to content

Commit

Permalink
AUT-936 Add ID-Card tests with revoked and unknown AUTH certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
Steinhain committed Jun 21, 2022
1 parent 2796e24 commit 34be69b
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 7 deletions.
46 changes: 39 additions & 7 deletions src/test/groovy/ee/ria/tara/IDCardAuthSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class IDCardAuthSpec extends TaraSpecification {
def "Init ID-Card authentication"() {
expect:
String certificate = Utils.getCertificateAsString("src/test/resources/joeorg-auth.pem")
Response initClientAuthenticationSession = Steps.startAuthenticationInTara(flow)
Steps.startAuthenticationInTara(flow)
HashMap<String, String> headersMap = (HashMap) Collections.emptyMap()
Utils.setParameter(headersMap, "XCLIENTCERTIFICATE", certificate)
Response response = Requests.idCardAuthentication(flow, headersMap)
Expand All @@ -43,7 +43,7 @@ class IDCardAuthSpec extends TaraSpecification {
def "Init ID-Card authentication with expired certificate"() {
expect:
String certificate = Utils.getCertificateAsString("src/test/resources/expired-cert.pem")
Response initClientAuthenticationSession = Steps.startAuthenticationInTara(flow)
Steps.startAuthenticationInTara(flow)
HashMap<String, String> headersMap = (HashMap) Collections.emptyMap()
Utils.setParameter(headersMap, "XCLIENTCERTIFICATE", certificate)
Response response = Requests.idCardAuthentication(flow, headersMap)
Expand All @@ -53,12 +53,44 @@ class IDCardAuthSpec extends TaraSpecification {
assertEquals("application/json;charset=UTF-8", response.getContentType(), "Correct Content-Type is returned")
}

@Unroll
@Feature("ESTEID_AUTH_ENDPOINT")
@Feature("REJECT_UNKNOWN_CERTS")
def "Init ID-Card authentication with revoked certificate"() {
expect:
String certificate = Utils.getCertificateAsString("src/test/resources/revoked-cert.pem")
Steps.startAuthenticationInTara(flow)
HashMap<String, String> headersMap = (HashMap) Collections.emptyMap()
Utils.setParameter(headersMap, "XCLIENTCERTIFICATE", certificate)
Response response = Requests.idCardAuthentication(flow, headersMap)
assertEquals(400, response.statusCode(), "Correct HTTP status code is returned")
assertThat("Correct response", response.body().jsonPath().get("status").toString(), equalTo("ERROR"))
assertThat("Correct error message", response.body().jsonPath().get("message").toString(), equalTo("ID-kaardi sertifikaadid on peatatud või tühistatud. Palun pöörduge Politsei- ja Piirivalveameti teenindusse."))
assertEquals("application/json;charset=UTF-8", response.getContentType(), "Correct Content-Type is returned")
}

@Unroll
@Feature("ESTEID_AUTH_ENDPOINT")
@Feature("REJECT_UNKNOWN_CERTS")
def "Init ID-Card authentication with unknown certificate"() {
expect:
String certificate = Utils.getCertificateAsString("src/test/resources/unknown-cert.pem")
Steps.startAuthenticationInTara(flow)
HashMap<String, String> headersMap = (HashMap) Collections.emptyMap()
Utils.setParameter(headersMap, "XCLIENTCERTIFICATE", certificate)
Response response = Requests.idCardAuthentication(flow, headersMap)
assertEquals(400, response.statusCode(), "Correct HTTP status code is returned")
assertThat("Correct response", response.body().jsonPath().get("status").toString(), equalTo("ERROR"))
assertThat("Correct error message", response.body().jsonPath().get("message").toString(), equalTo("ID-kaardi sertifikaadid on peatatud või tühistatud. Palun pöörduge Politsei- ja Piirivalveameti teenindusse."))
assertEquals("application/json;charset=UTF-8", response.getContentType(), "Correct Content-Type is returned")
}

@Unroll
@Feature("IDCARD_AUTH_SUCCESSFUL")
def "Authenticate with ID-Card"() {
expect:
String certificate = Utils.getCertificateAsString("src/test/resources/joeorg-auth.pem")
Response initClientAuthenticationSession = Steps.startAuthenticationInTara(flow)
Steps.startAuthenticationInTara(flow)
HashMap<String, String> headersMap = (HashMap) Collections.emptyMap()
Utils.setParameter(headersMap, "XCLIENTCERTIFICATE", certificate)
Response response = Requests.idCardAuthentication(flow, headersMap)
Expand Down Expand Up @@ -97,7 +129,7 @@ class IDCardAuthSpec extends TaraSpecification {
def "Authenticate with ID-Card. Esteid 2015 chain certificate"() {
expect:
String certificate = Utils.getCertificateAsString("src/test/resources/Mari-Liis-Esteid-2015_auth.pem")
Response initClientAuthenticationSession = Steps.startAuthenticationInTara(flow)
Steps.startAuthenticationInTara(flow)
HashMap<String, String> headersMap = (HashMap) Collections.emptyMap()
Utils.setParameter(headersMap, "XCLIENTCERTIFICATE", certificate)
Response response = Requests.idCardAuthentication(flow, headersMap)
Expand Down Expand Up @@ -141,7 +173,7 @@ class IDCardAuthSpec extends TaraSpecification {
def "Verify ID-Card authentication response headers"() {
expect:
String certificate = Utils.getCertificateAsString("src/test/resources/joeorg-auth.pem")
Response initClientAuthenticationSession = Steps.startAuthenticationInTara(flow)
Steps.startAuthenticationInTara(flow)
HashMap<String, String> headersMap = (HashMap) Collections.emptyMap()
Utils.setParameter(headersMap, "XCLIENTCERTIFICATE", certificate)
Response response = Requests.idCardAuthentication(flow, headersMap)
Expand All @@ -154,7 +186,7 @@ class IDCardAuthSpec extends TaraSpecification {
def "Init ID-Card authentication with invalid session"() {
expect:
String certificate = Utils.getCertificateAsString("src/test/resources/joeorg-auth.pem")
Response initClientAuthenticationSession = Steps.startAuthenticationInTara(flow)
Steps.startAuthenticationInTara(flow)
HashMap<String, String> headersMap = (HashMap) Collections.emptyMap()
Utils.setParameter(headersMap, "XCLIENTCERTIFICATE", certificate)
flow.setSessionId("123456789")
Expand All @@ -170,7 +202,7 @@ class IDCardAuthSpec extends TaraSpecification {
def "Init ID-Card authentication with missing session cookie"() {
expect:
String certificate = Utils.getCertificateAsString("src/test/resources/joeorg-auth.pem")
Response initClientAuthenticationSession = Steps.startAuthenticationInTara(flow)
Steps.startAuthenticationInTara(flow)
HashMap<String, String> headersMap = (HashMap) Collections.emptyMap()
Utils.setParameter(headersMap, "XCLIENTCERTIFICATE", certificate)
Response response = Requests.idCardAuthenticationWithoutSession(flow, headersMap)
Expand Down
24 changes: 24 additions & 0 deletions src/test/resources/revoked-cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-----BEGIN CERTIFICATE-----
MIIEDjCCA2+gAwIBAgIQV+LMA+DL5AtcyshOw6C/kzAKBggqhkjOPQQDBDBgMQsw
CQYDVQQGEw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BggrBgEFBQcwAoYpaHR0cDovL2Muc2suZWUvVGVz
dF9vZl9FU1RFSUQyMDE4LmRlci5jcnQwCgYIKoZIzj0EAwQDgYwAMIGIAkIAh/ZY
LzGO80Dbh08tDInz1AYhxXsp+iEk+6fdXyPLmXNt3zlH+udzIC33XtDXhJ3xjMiD
t/QbmNwfXIE12TCSPUACQgCWkyVDf3h8ex9UbCkEmBMv3TBbHrQU8Fyfat9qRf9N
eqFtuScOLrPkDXGqCTgEa4Olj7BYmBrQDG5WDV4mEmHWkA==
-----END CERTIFICATE-----
24 changes: 24 additions & 0 deletions src/test/resources/unknown-cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-----BEGIN CERTIFICATE-----
MIID7TCCA0+gAwIBAgIQF2q2ts5+lGVcyskEJYEhdDAKBggqhkjOPQQDBDBgMQsw
CQYDVQQGEwJFRTEbMBkGA1UECgwSU0sgSUQgU29sdXRpb25zIEFTMRcwFQYDVQRh
DA5OVFJFRS0xMDc0NzAxMzEbMBkGA1UEAwwSVEVTVCBvZiBFU1RFSUQyMDE4MB4X
DTE5MDUwMjEwNDAwNFoXDTI5MDUwMjEwNDAwNFowfzELMAkGA1UEBhMCRUUxFjAU
BgNVBCoMDUpBQUstS1JJU1RKQU4xEDAOBgNVBAQMB0rDlUVPUkcxKjAoBgNVBAMM
IUrDlUVPUkcsSkFBSy1LUklTVEpBTiwzODAwMTA4NTcxODEaMBgGA1UEBRMRUE5P
RUUtMzgwMDEwODU3MTgwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDucCo8W0S0rsA
AMCxmmMI4SVPY/zfCppYrH6rElG9oJ30Ktsuw6KrCDwr0I8u+49ZX6meluG8FV3s
Q/KfnYT2hyZRsBETNGGvnyFhoDY1leUjrvf1KnbyhPlsdwZW6eqjggGtMIIBqTAJ
BgNVHRMEAjAAMA4GA1UdDwEB/wQEAwIDiDBHBgNVHSAEQDA+MDIGCysGAQQBg5Eh
AQIBMCMwIQYIKwYBBQU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