From 563cf620873c01d09ba536e1979d39123a754908 Mon Sep 17 00:00:00 2001 From: Michele Mastrogiovanni Date: Mon, 4 Jan 2021 15:05:23 +0100 Subject: [PATCH 1/3] #19 changed test endpoint for CIE middleware --- README.md | 4 ++-- src/__tests__/index.test.ts | 2 +- src/example.ts | 2 +- src/strategy/__tests__/saml_client.test.ts | 2 +- src/utils/__tests__/middleware.test.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8912e417..4ffe2e5a 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ L'oggetto `serviceProviderConfig` contiene i parametri del Service Provider. Es: ], name: "Required attrs" }, - spidCieUrl: "https://idserver.servizicie.interno.gov.it:8443/idp/shibboleth", + spidCieUrl: "https://preproduzione.idserver.servizicie.interno.gov.it/idp/shibboleth?Metadata", spidTestEnvUrl: "https://spid-testenv2:8088", spidValidatorUrl: "http://localhost:8080", strictResponseValidation: { @@ -189,7 +189,7 @@ L'oggetto `serviceProviderConfig` contiene i parametri del Service Provider. Es: (identificativi in ). * **`spidCieUrl`**: URL per l'accesso con Carta d'Identità elettronica ("Entra con CIE"). - Impostare a "`https://idserver.servizicie.interno.gov.it:8443/idp/shibboleth`" + Impostare a "`https://preproduzione.idserver.servizicie.interno.gov.it/idp/shibboleth?Metadata`" per lo sviluppo. * **`spidTestEnvUrl`**: URL dell'istanza di [spid-testenv2](https://github.com/italia/spid-testenv2). Lasciare vuoto per disabilitare. diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 3ddc8870..651928aa 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -82,7 +82,7 @@ const spidTestEnvUrl = "https://localhost:8088"; const IDPMetadataUrl = "https://registry.spid.gov.it/metadata/idp/spid-entities-idps.xml"; const spidCieUrl = - "https://idserver.servizicie.interno.gov.it:8443/idp/shibboleth"; + "https://preproduzione.idserver.servizicie.interno.gov.it/idp/shibboleth?Metadata"; const expectedLoginPath = "/login"; const expectedSloPath = "/logout"; diff --git a/src/example.ts b/src/example.ts index 81d07168..e91ed4ab 100644 --- a/src/example.ts +++ b/src/example.ts @@ -71,7 +71,7 @@ const serviceProviderConfig: IServiceProviderConfig = { ], name: "Required attrs" }, - spidCieUrl: "https://idserver.servizicie.interno.gov.it:8443/idp/shibboleth", + spidCieUrl: "https://preproduzione.idserver.servizicie.interno.gov.it/idp/shibboleth?Metadata", spidTestEnvUrl: "https://spid-testenv2:8088", spidValidatorUrl: "http://localhost:8080", strictResponseValidation: { diff --git a/src/strategy/__tests__/saml_client.test.ts b/src/strategy/__tests__/saml_client.test.ts index ee3c178c..24952c1a 100644 --- a/src/strategy/__tests__/saml_client.test.ts +++ b/src/strategy/__tests__/saml_client.test.ts @@ -44,7 +44,7 @@ const serviceProviderConfig: IServiceProviderConfig = { ], name: "Required attrs" }, - spidCieUrl: "https://idserver.servizicie.interno.gov.it:8443/idp/shibboleth", + spidCieUrl: "https://preproduzione.idserver.servizicie.interno.gov.it/idp/shibboleth?Metadata", spidTestEnvUrl: "https://spid-testenv2:8088", spidValidatorUrl: "http://localhost:8080" }; diff --git a/src/utils/__tests__/middleware.test.ts b/src/utils/__tests__/middleware.test.ts index 6ff26b8a..7e3ae7af 100644 --- a/src/utils/__tests__/middleware.test.ts +++ b/src/utils/__tests__/middleware.test.ts @@ -20,7 +20,7 @@ const mockFetchIdpsMetadata = jest.spyOn(metadata, "fetchIdpsMetadata"); const idpMetadataUrl = "http://ipd.metadata.example/metadata.xml"; const cieMetadataUrl = - "https://idserver.servizicie.interno.gov.it:8443/idp/shibboleth"; + "https://preproduzione.idserver.servizicie.interno.gov.it/idp/shibboleth?Metadata"; const spidTestEnvUrl = "https://spid-testenv2:8088"; const serviceProviderConfig: IServiceProviderConfig = { From cebcb86916a6e48e1a99a27bac12a173d6d17f44 Mon Sep 17 00:00:00 2001 From: Michele Mastrogiovanni Date: Mon, 4 Jan 2021 15:55:17 +0100 Subject: [PATCH 2/3] Fixed CIE's IDP identifier --- src/config.ts | 2 +- src/example.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/config.ts b/src/config.ts index 372e8283..8c392303 100644 --- a/src/config.ts +++ b/src/config.ts @@ -13,7 +13,7 @@ export const SPID_IDP_IDENTIFIERS = { export const CIE_IDP_IDENTIFIERS = { "https://idserver.servizicie.interno.gov.it/idp/profile/SAML2/POST/SSO": "xx_servizicie", - "https://idserver.servizicie.interno.gov.it:8443/idp/profile/SAML2/POST/SSO": + "https://preproduzione.idserver.servizicie.interno.gov.it/idp/profile/SAML2/POST/SSO": "xx_servizicie_test" }; diff --git a/src/example.ts b/src/example.ts index e91ed4ab..076738f0 100644 --- a/src/example.ts +++ b/src/example.ts @@ -92,7 +92,8 @@ const samlConfig: SamlConfig = { callbackUrl: "http://localhost:3000" + appConfig.assertionConsumerServicePath, // decryptionPvk: fs.readFileSync("./certs/key.pem", "utf-8"), identifierFormat: "urn:oasis:names:tc:SAML:2.0:nameid-format:transient", - issuer: "https://spid.agid.gov.it/cd", + issuer: "https://test.gov.it/sp", + idpIssuer: "https://test.gov.it/sp", logoutCallbackUrl: "http://localhost:3000/slo", privateCert: fs.readFileSync("./certs/key.pem", "utf-8"), validateInResponseTo: true From f27c8f599e33f3130c2ced7f654740a85b0f2d68 Mon Sep 17 00:00:00 2001 From: Michele Mastrogiovanni Date: Mon, 4 Jan 2021 16:40:59 +0100 Subject: [PATCH 3/3] Fixed tests --- src/__mocks__/metadata.ts | 4 ++-- src/example.ts | 6 ++--- src/utils/__mocks__/cie-idp-metadata.ts | 30 ++++++++++++------------- src/utils/__mocks__/saml.ts | 6 ++--- src/utils/__tests__/metadata.test.ts | 7 +++--- src/utils/__tests__/saml.test.ts | 2 +- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/__mocks__/metadata.ts b/src/__mocks__/metadata.ts index f9704357..43a2e212 100644 --- a/src/__mocks__/metadata.ts +++ b/src/__mocks__/metadata.ts @@ -17,9 +17,9 @@ export const mockCIEIdpMetadata: Record = { xx_servizicie_test: { cert: (["CERT"] as unknown) as NonEmptyArray, entityID: - "https://idserver.servizicie.interno.gov.it:8443/idp/profile/SAML2/POST/SSO", + "https://preproduzione.idserver.servizicie.interno.gov.it/idp/profile/SAML2/POST/SSO", entryPoint: - "https://idserver.servizicie.interno.gov.it:8443/idp/profile/SAML2/Redirect/SSO", + "https://preproduzione.idserver.servizicie.interno.gov.it/idp/profile/SAML2/POST/SSO", logoutUrl: "" } }; diff --git a/src/example.ts b/src/example.ts index 076738f0..78c9ebcb 100644 --- a/src/example.ts +++ b/src/example.ts @@ -71,7 +71,8 @@ const serviceProviderConfig: IServiceProviderConfig = { ], name: "Required attrs" }, - spidCieUrl: "https://preproduzione.idserver.servizicie.interno.gov.it/idp/shibboleth?Metadata", + spidCieUrl: + "https://preproduzione.idserver.servizicie.interno.gov.it/idp/shibboleth?Metadata", spidTestEnvUrl: "https://spid-testenv2:8088", spidValidatorUrl: "http://localhost:8080", strictResponseValidation: { @@ -92,8 +93,7 @@ const samlConfig: SamlConfig = { callbackUrl: "http://localhost:3000" + appConfig.assertionConsumerServicePath, // decryptionPvk: fs.readFileSync("./certs/key.pem", "utf-8"), identifierFormat: "urn:oasis:names:tc:SAML:2.0:nameid-format:transient", - issuer: "https://test.gov.it/sp", - idpIssuer: "https://test.gov.it/sp", + issuer: "https://spid.agid.gov.it/cd", logoutCallbackUrl: "http://localhost:3000/slo", privateCert: fs.readFileSync("./certs/key.pem", "utf-8"), validateInResponseTo: true diff --git a/src/utils/__mocks__/cie-idp-metadata.ts b/src/utils/__mocks__/cie-idp-metadata.ts index fe5f0cfc..3a68aa78 100644 --- a/src/utils/__mocks__/cie-idp-metadata.ts +++ b/src/utils/__mocks__/cie-idp-metadata.ts @@ -5,7 +5,7 @@ export default ` This metadata is not dynamic - it will not change as your configuration changes. --> - + @@ -79,20 +79,20 @@ export default ` - - + + - + + + + + + - - - - + + + + @@ -161,8 +161,8 @@ export default ` - - + + diff --git a/src/utils/__mocks__/saml.ts b/src/utils/__mocks__/saml.ts index 2c62279e..1482638f 100644 --- a/src/utils/__mocks__/saml.ts +++ b/src/utils/__mocks__/saml.ts @@ -183,7 +183,7 @@ export const samlResponseCIE = ` - https://idserver.servizicie.interno.gov.it:8443/idp/profile/SAML2/POST/SSO + https://preproduzione.idserver.servizicie.interno.gov.it/idp/profile/SAML2/POST/SSO @@ -215,7 +215,7 @@ AIa2vTA8uOKizFvCqNchj4Dby8eDOi5UaOEZYJ4NV0RorEj2wkSFbhX65FYLt68VUGY5YR1tqDfl d0A - https://idserver.servizicie.interno.gov.it:8443/idp/profile/SAML2/POST/SSO + https://preproduzione.idserver.servizicie.interno.gov.it/idp/profile/SAML2/POST/SSO @@ -242,7 +242,7 @@ UJ23xMKOYhCcRVunnDgor2WLqHEgYeyaAhHr16+kkO6poPog2a9PoiqGUU0Dg+YMvHRJVq0h0sKz M1z - AAdzZWNyZXQxqDU6XhTO1MGlMAoXjWFIOcPfK4AhIPsnBAoTNelku/jA7/XaogQJhOrgxCiAIqavL2GUQqQ7VMYPRryyteifD34fsyrHmbPNr1Tz2YJe8wgENUlDvaY31unC/P1kwqTZ17jQYw3qoVZs4neWi9ZUo9j8BoiDAHdoyOOoTiVbDA== + AAdzZWNyZXQxqDU6XhTO1MGlMAoXjWFIOcPfK4AhIPsnBAoTNelku/jA7/XaogQJhOrgxCiAIqavL2GUQqQ7VMYPRryyteifD34fsyrHmbPNr1Tz2YJe8wgENUlDvaY31unC/P1kwqTZ17jQYw3qoVZs4neWi9ZUo9j8BoiDAHdoyOOoTiVbDA== diff --git a/src/utils/__tests__/metadata.test.ts b/src/utils/__tests__/metadata.test.ts index 42299a41..157e9ec8 100644 --- a/src/utils/__tests__/metadata.test.ts +++ b/src/utils/__tests__/metadata.test.ts @@ -75,10 +75,11 @@ describe("fetchIdpsMetadata", () => { expect(result.value).toHaveProperty("xx_servizicie_test", { cert: expect.any(NonEmptyArray), entityID: - "https://idserver.servizicie.interno.gov.it:8443/idp/profile/SAML2/POST/SSO", + "https://preproduzione.idserver.servizicie.interno.gov.it/idp/profile/SAML2/POST/SSO", entryPoint: - "https://idserver.servizicie.interno.gov.it:8443/idp/profile/SAML2/Redirect/SSO", - logoutUrl: "" + "https://preproduzione.idserver.servizicie.interno.gov.it/idp/profile/SAML2/Redirect/SSO", + logoutUrl: + "https://preproduzione.idserver.servizicie.interno.gov.it/idp/profile/SAML2/Redirect/SLO" }); }); diff --git a/src/utils/__tests__/saml.test.ts b/src/utils/__tests__/saml.test.ts index 5926171c..59f519fb 100644 --- a/src/utils/__tests__/saml.test.ts +++ b/src/utils/__tests__/saml.test.ts @@ -363,7 +363,7 @@ describe("preValidateResponse", () => { RequestXML: samlRequest, createdAt: "2020-02-26T07:27:42Z", idpIssuer: - "https://idserver.servizicie.interno.gov.it:8443/idp/profile/SAML2/POST/SSO" + "https://preproduzione.idserver.servizicie.interno.gov.it/idp/profile/SAML2/POST/SSO" }) ); });