From 717c078bce2fcfe08ff19a284b07e9a7564df99f Mon Sep 17 00:00:00 2001 From: julien mounier Date: Wed, 17 Jul 2024 14:05:08 +0200 Subject: [PATCH] fix(tests): migrate fake-oidc endpoints to /issuers/fake-oidc --- modules/admin/include/Tanker/Admin/Client.hpp | 1 + modules/admin/src/Client.cpp | 1 + .../include/Tanker/Functional/TrustchainFactory.hpp | 2 +- modules/functional-helpers/src/TrustchainFactory.cpp | 7 +++++-- modules/functional-tests/test_verification.cpp | 2 +- modules/test-helpers/src/Config.cpp | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/admin/include/Tanker/Admin/Client.hpp b/modules/admin/include/Tanker/Admin/Client.hpp index a113f7143..b2b38be11 100644 --- a/modules/admin/include/Tanker/Admin/Client.hpp +++ b/modules/admin/include/Tanker/Admin/Client.hpp @@ -23,6 +23,7 @@ struct OidcConfiguration std::string displayName; std::string clientId; std::string issuer; + std::string oidcProviderGroupId; }; struct App diff --git a/modules/admin/src/Client.cpp b/modules/admin/src/Client.cpp index 4cc144132..a8f541782 100644 --- a/modules/admin/src/Client.cpp +++ b/modules/admin/src/Client.cpp @@ -138,6 +138,7 @@ tc::cotask Client::update(Trustchain::TrustchainId const& trustchainId, App auto providerJson = nlohmann::json{{"client_id", provider.clientId}, {"issuer", provider.issuer}, {"display_name", provider.displayName}, + {"oidc_provider_group_id", provider.oidcProviderGroupId}, {"ignore_token_expiration", ignoreTokenExpiration}}; body["oidc_providers"] = nlohmann::json::array({providerJson}); } diff --git a/modules/functional-helpers/include/Tanker/Functional/TrustchainFactory.hpp b/modules/functional-helpers/include/Tanker/Functional/TrustchainFactory.hpp index 95188364e..d665d2854 100644 --- a/modules/functional-helpers/include/Tanker/Functional/TrustchainFactory.hpp +++ b/modules/functional-helpers/include/Tanker/Functional/TrustchainFactory.hpp @@ -34,7 +34,7 @@ class TrustchainFactory tc::cotask createTrustchain(std::string const& name); tc::cotask useTrustchain(std::string configPath); tc::cotask enableOidc(Tanker::Trustchain::TrustchainId const& id); - tc::cotask enableFakeOidc(Tanker::Trustchain::TrustchainId const& id); + tc::cotask enableFakeOidc(Tanker::Trustchain::TrustchainId const& id, std::string const& issuer = "main", std::string const& providerGroupId = "BxFm1n2_wR2V02gbO-tRK68rTiOwPps0L_hGjxkHofM"); tc::cotask enablePSCOidc(Tanker::Trustchain::TrustchainId const& id, PSCProvider const& provider); tc::cotask setUserEnrollmentEnabled(Tanker::Trustchain::TrustchainId const& id, bool state = true); diff --git a/modules/functional-helpers/src/TrustchainFactory.cpp b/modules/functional-helpers/src/TrustchainFactory.cpp index 1df9d3163..783072f79 100644 --- a/modules/functional-helpers/src/TrustchainFactory.cpp +++ b/modules/functional-helpers/src/TrustchainFactory.cpp @@ -48,19 +48,21 @@ tc::cotask TrustchainFactory::enableOidc(Tanker::Trustchain::TrustchainId adminOidcConf.displayName = oidcConfig.displayName; adminOidcConf.clientId = oidcConfig.clientId; adminOidcConf.issuer = oidcConfig.issuer; + adminOidcConf.oidcProviderGroupId = "qYjh0nn2C5s8mj9d-F4Oy8UhFqVTNZpnuwE55lWHV7Y"; Admin::AppUpdateOptions options{}; options.oidcProvider = adminOidcConf; TC_AWAIT(_admin->update(id, options)); } -tc::cotask TrustchainFactory::enableFakeOidc(Tanker::Trustchain::TrustchainId const& id) +tc::cotask TrustchainFactory::enableFakeOidc(Tanker::Trustchain::TrustchainId const& id, std::string const& issuer, std::string const& providerGroupId) { auto const& fakeOidcIssuerUrl = TestConstants::oidcConfig().fakeOidcIssuerUrl; Admin::OidcConfiguration adminOidcConf{}; adminOidcConf.displayName = "fake-oidc"; adminOidcConf.clientId = "tanker"; - adminOidcConf.issuer = fakeOidcIssuerUrl; + adminOidcConf.issuer = fakeOidcIssuerUrl + "/" + issuer; + adminOidcConf.oidcProviderGroupId = providerGroupId; Admin::AppUpdateOptions options{}; options.oidcProvider = adminOidcConf; @@ -87,6 +89,7 @@ tc::cotask TrustchainFactory::enablePSCOidc(Tanker::Trustchain::Trustchain adminOidcConf.displayName = to_string(provider); adminOidcConf.clientId = "doctolib-dev"; adminOidcConf.issuer = "https://auth.bas.psc.esante.gouv.fr/auth/realms/esante-wallet"; + adminOidcConf.oidcProviderGroupId = "m-DsT9cPgBqoQJPFI3IOMBPobofKvjzXEPA6kOfnCuA"; Admin::AppUpdateOptions options{}; options.oidcProvider = adminOidcConf; diff --git a/modules/functional-tests/test_verification.cpp b/modules/functional-tests/test_verification.cpp index 417e36489..e48c3eaa7 100644 --- a/modules/functional-tests/test_verification.cpp +++ b/modules/functional-tests/test_verification.cpp @@ -986,7 +986,7 @@ TEST_CASE_METHOD(TrustchainFixture, "verification by oidc authorization code") auto martinePhone = martineDevice2.createCore(); auto const subjectCookie = "fake_oidc_subject=martine"; - auto const fakeOidcIssuerUrl = TestConstants::oidcConfig().fakeOidcIssuerUrl; + auto const fakeOidcIssuerUrl = TestConstants::oidcConfig().fakeOidcIssuerUrl + "/main"; auto const providerId = oidcProviderId(martineLaptop->sdkInfo().trustchainId, fakeOidcIssuerUrl, "tanker"); diff --git a/modules/test-helpers/src/Config.cpp b/modules/test-helpers/src/Config.cpp index ad338f52f..0089fa321 100644 --- a/modules/test-helpers/src/Config.cpp +++ b/modules/test-helpers/src/Config.cpp @@ -32,7 +32,7 @@ OidcConfig const& oidcConfig() getSafeEnv("TANKER_OIDC_ISSUER"), {{"kevin", {getSafeEnv("TANKER_OIDC_KEVIN_EMAIL"), getSafeEnv("TANKER_OIDC_KEVIN_REFRESH_TOKEN")}}, {"martine", {getSafeEnv("TANKER_OIDC_MARTINE_EMAIL"), getSafeEnv("TANKER_OIDC_MARTINE_REFRESH_TOKEN")}}}, - getSafeEnv("TANKER_FAKE_OIDC_URL") + "/issuer", + getSafeEnv("TANKER_FAKE_OIDC_URL") + "/issuers", }; return oidc; }