From bdb958341db554555aee0f9df1e751708e37afc6 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Tue, 6 Feb 2024 19:41:31 +0530 Subject: [PATCH 1/2] fix: test --- .../test/multitenant/LoadOnlyCUDTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/test/java/io/supertokens/test/multitenant/LoadOnlyCUDTest.java b/src/test/java/io/supertokens/test/multitenant/LoadOnlyCUDTest.java index 053420b04..e08f0b234 100644 --- a/src/test/java/io/supertokens/test/multitenant/LoadOnlyCUDTest.java +++ b/src/test/java/io/supertokens/test/multitenant/LoadOnlyCUDTest.java @@ -69,6 +69,14 @@ public void testAPIChecksForLoadOnlyCUD() throws Exception { process.startProcess(); assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED)); + if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { + return; + } + + if (StorageLayer.isInMemDb(process.getProcess())) { + return; + } + JsonObject coreConfig = new JsonObject(); StorageLayer.getStorage(process.getProcess()).modifyConfigToAddANewUserPoolForTesting(coreConfig, 1); @@ -119,6 +127,10 @@ public void testCreationOfCUDWithLoadOnlyCUD() throws Exception { return; } + if (StorageLayer.isInMemDb(process.getProcess())) { + return; + } + try { TestMultitenancyAPIHelper.createConnectionUriDomain(process.getProcess(), TenantIdentifier.BASE_TENANT, "localhost:3567", true, true, true, new JsonObject()); @@ -147,6 +159,14 @@ public void testThatResourcesAreNotLoadedWithLoadOnlyCUD() throws Exception { process.startProcess(); assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED)); + if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { + return; + } + + if (StorageLayer.isInMemDb(process.getProcess())) { + return; + } + JsonObject coreConfig = new JsonObject(); StorageLayer.getStorage(process.getProcess()).modifyConfigToAddANewUserPoolForTesting(coreConfig, 1); TestMultitenancyAPIHelper.createConnectionUriDomain(process.getProcess(), TenantIdentifier.BASE_TENANT, @@ -186,6 +206,14 @@ public void testCronDoesNotRunForOtherCUDsWithLoadOnlyCUD() throws Exception { process.startProcess(); assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED)); + if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { + return; + } + + if (StorageLayer.isInMemDb(process.getProcess())) { + return; + } + JsonObject coreConfig = new JsonObject(); StorageLayer.getStorage(process.getProcess()).modifyConfigToAddANewUserPoolForTesting(coreConfig, 1); TestMultitenancyAPIHelper.createConnectionUriDomain(process.getProcess(), TenantIdentifier.BASE_TENANT, From 68c6d876a6c3933c552f25b7273680682bd880ce Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Wed, 7 Feb 2024 10:51:30 +0530 Subject: [PATCH 2/2] fix: tests --- .../io/supertokens/test/PathRouterTest.java | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/test/java/io/supertokens/test/PathRouterTest.java b/src/test/java/io/supertokens/test/PathRouterTest.java index 555007e24..e72daae9b 100644 --- a/src/test/java/io/supertokens/test/PathRouterTest.java +++ b/src/test/java/io/supertokens/test/PathRouterTest.java @@ -1533,7 +1533,9 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I public void tenantNotFoundTest3() throws InterruptedException, IOException, io.supertokens.httpRequest.HttpResponseException, InvalidConfigException, - io.supertokens.test.httpRequest.HttpResponseException, TenantOrAppNotFoundException { + io.supertokens.test.httpRequest.HttpResponseException, TenantOrAppNotFoundException, + InvalidProviderConfigException, StorageQueryException, FeatureNotEnabledException, + CannotModifyBaseConfigException, BadPermissionException { String[] args = {"../"}; Utils.setValueInConfig("host", "\"0.0.0.0\""); @@ -1556,15 +1558,26 @@ public void tenantNotFoundTest3() StorageLayer.getStorage(new TenantIdentifier(null, null, null), process.getProcess()) .modifyConfigToAddANewUserPoolForTesting(tenantConfig, 2); - Config.loadAllTenantConfig(process.getProcess(), new TenantConfig[]{ - new TenantConfig(new TenantIdentifier("localhost", null, null), new EmailPasswordConfig(false), + Multitenancy.addNewOrUpdateAppOrTenant( + process.getProcess(), + new TenantConfig( + new TenantIdentifier("localhost", null, null), + new EmailPasswordConfig(false), new ThirdPartyConfig(false, new ThirdPartyConfig.Provider[0]), new PasswordlessConfig(false), tenantConfig), - new TenantConfig(new TenantIdentifier("localhost", null, "t1"), new EmailPasswordConfig(false), + false + ); + Multitenancy.addNewOrUpdateAppOrTenant( + process.getProcess(), + new TenantConfig( + new TenantIdentifier("localhost", null, "t1"), + new EmailPasswordConfig(false), new ThirdPartyConfig(false, new ThirdPartyConfig.Provider[0]), new PasswordlessConfig(false), - tenantConfig)}, new ArrayList<>()); + tenantConfig), + false + ); Webserver.getInstance(process.getProcess()).addAPI(new WebserverAPI(process.getProcess(), "") { @@ -2788,7 +2801,9 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I public void tenantNotFoundWithAppIdTest3() throws InterruptedException, IOException, io.supertokens.httpRequest.HttpResponseException, InvalidConfigException, - io.supertokens.test.httpRequest.HttpResponseException, TenantOrAppNotFoundException { + io.supertokens.test.httpRequest.HttpResponseException, TenantOrAppNotFoundException, + InvalidProviderConfigException, StorageQueryException, FeatureNotEnabledException, + CannotModifyBaseConfigException, BadPermissionException { String[] args = {"../"}; Utils.setValueInConfig("host", "\"0.0.0.0\""); @@ -2811,15 +2826,26 @@ public void tenantNotFoundWithAppIdTest3() StorageLayer.getStorage(new TenantIdentifier(null, null, null), process.getProcess()) .modifyConfigToAddANewUserPoolForTesting(tenantConfig, 2); - Config.loadAllTenantConfig(process.getProcess(), new TenantConfig[]{ - new TenantConfig(new TenantIdentifier("localhost", null, null), new EmailPasswordConfig(false), + Multitenancy.addNewOrUpdateAppOrTenant( + process.getProcess(), + new TenantConfig( + new TenantIdentifier("localhost", null, null), + new EmailPasswordConfig(false), new ThirdPartyConfig(false, new ThirdPartyConfig.Provider[0]), new PasswordlessConfig(false), tenantConfig), - new TenantConfig(new TenantIdentifier("localhost", "app1", "t1"), new EmailPasswordConfig(false), + false + ); + Multitenancy.addNewOrUpdateAppOrTenant( + process.getProcess(), + new TenantConfig( + new TenantIdentifier("localhost", "app1", "t1"), + new EmailPasswordConfig(false), new ThirdPartyConfig(false, new ThirdPartyConfig.Provider[0]), new PasswordlessConfig(false), - tenantConfig)}, new ArrayList<>()); + tenantConfig), + false + ); Webserver.getInstance(process.getProcess()).addAPI(new WebserverAPI(process.getProcess(), "") {