Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Test fix #921

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 36 additions & 10 deletions src/test/java/io/supertokens/test/PathRouterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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\"");
Expand All @@ -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(), "") {

Expand Down Expand Up @@ -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\"");
Expand All @@ -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(), "") {

Expand Down
28 changes: 28 additions & 0 deletions src/test/java/io/supertokens/test/multitenant/LoadOnlyCUDTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading