Skip to content

Commit

Permalink
fix(tests): migrate fake-oidc endpoints to /issuers/fake-oidc
Browse files Browse the repository at this point in the history
  • Loading branch information
JMounier committed Jul 19, 2024
1 parent fb1be5b commit 717c078
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions modules/admin/include/Tanker/Admin/Client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct OidcConfiguration
std::string displayName;
std::string clientId;
std::string issuer;
std::string oidcProviderGroupId;
};

struct App
Expand Down
1 change: 1 addition & 0 deletions modules/admin/src/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ tc::cotask<App> 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});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TrustchainFactory
tc::cotask<Trustchain::Ptr> createTrustchain(std::string const& name);
tc::cotask<Trustchain::Ptr> useTrustchain(std::string configPath);
tc::cotask<void> enableOidc(Tanker::Trustchain::TrustchainId const& id);
tc::cotask<void> enableFakeOidc(Tanker::Trustchain::TrustchainId const& id);
tc::cotask<void> enableFakeOidc(Tanker::Trustchain::TrustchainId const& id, std::string const& issuer = "main", std::string const& providerGroupId = "BxFm1n2_wR2V02gbO-tRK68rTiOwPps0L_hGjxkHofM");
tc::cotask<void> enablePSCOidc(Tanker::Trustchain::TrustchainId const& id, PSCProvider const& provider);
tc::cotask<void> setUserEnrollmentEnabled(Tanker::Trustchain::TrustchainId const& id, bool state = true);

Expand Down
7 changes: 5 additions & 2 deletions modules/functional-helpers/src/TrustchainFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,21 @@ tc::cotask<void> 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<void> TrustchainFactory::enableFakeOidc(Tanker::Trustchain::TrustchainId const& id)
tc::cotask<void> 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;
Expand All @@ -87,6 +89,7 @@ tc::cotask<void> 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;
Expand Down
2 changes: 1 addition & 1 deletion modules/functional-tests/test_verification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion modules/test-helpers/src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 717c078

Please sign in to comment.