-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,11 +18,14 @@ | |
|
||
import com.google.gson.JsonObject; | ||
import io.supertokens.ProcessState; | ||
import io.supertokens.passwordless.Passwordless; | ||
import io.supertokens.pluginInterface.STORAGE_TYPE; | ||
import io.supertokens.pluginInterface.authRecipe.AuthRecipeUserInfo; | ||
import io.supertokens.storageLayer.StorageLayer; | ||
import io.supertokens.test.TestingProcessManager; | ||
import io.supertokens.test.Utils; | ||
import io.supertokens.test.httpRequest.HttpRequestForTesting; | ||
import io.supertokens.thirdparty.ThirdParty; | ||
import io.supertokens.utils.SemVer; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
|
@@ -194,4 +197,44 @@ public void testForAllTypesOfOutput() throws Exception { | |
process.kill(); | ||
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STOPPED)); | ||
} | ||
|
||
@Test | ||
public void testGetUserForUsersOfOtherRecipeIds() throws Exception { | ||
String[] args = {"../"}; | ||
|
||
TestingProcessManager.TestingProcess process = TestingProcessManager.start(args); | ||
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED)); | ||
|
||
if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { | ||
return; | ||
} | ||
|
||
AuthRecipeUserInfo user1 = ThirdParty.signInUp(process.getProcess(), "google", "googleid", "[email protected]").user; | ||
Passwordless.CreateCodeResponse user2code = Passwordless.createCode(process.getProcess(), "[email protected]", | ||
null, null, null); | ||
AuthRecipeUserInfo user2 = Passwordless.consumeCode(process.getProcess(), user2code.deviceId, user2code.deviceIdHash, user2code.userInputCode, null).user; | ||
|
||
{ | ||
HashMap<String, String> map = new HashMap<>(); | ||
map.put("userId", user1.getSupertokensUserId()); | ||
|
||
JsonObject response = HttpRequestForTesting.sendGETRequest(process.getProcess(), "", | ||
"http://localhost:3567/recipe/user", map, 1000, 1000, null, SemVer.v2_7.get(), | ||
"emailpassword"); | ||
assertEquals(response.get("status").getAsString(), "UNKNOWN_USER_ID_ERROR"); | ||
} | ||
|
||
{ | ||
HashMap<String, String> map = new HashMap<>(); | ||
map.put("userId", user2.getSupertokensUserId()); | ||
|
||
JsonObject response = HttpRequestForTesting.sendGETRequest(process.getProcess(), "", | ||
"http://localhost:3567/recipe/user", map, 1000, 1000, null, SemVer.v2_7.get(), | ||
"emailpassword"); | ||
assertEquals(response.get("status").getAsString(), "UNKNOWN_USER_ID_ERROR"); | ||
} | ||
|
||
process.kill(); | ||
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STOPPED)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,18 @@ | |
|
||
import com.google.gson.JsonObject; | ||
import io.supertokens.ProcessState; | ||
import io.supertokens.emailpassword.EmailPassword; | ||
import io.supertokens.passwordless.Passwordless; | ||
import io.supertokens.pluginInterface.STORAGE_TYPE; | ||
import io.supertokens.pluginInterface.authRecipe.AuthRecipeUserInfo; | ||
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier; | ||
import io.supertokens.pluginInterface.passwordless.PasswordlessStorage; | ||
import io.supertokens.storageLayer.StorageLayer; | ||
import io.supertokens.test.TestingProcessManager; | ||
import io.supertokens.test.Utils; | ||
import io.supertokens.test.httpRequest.HttpRequestForTesting; | ||
|
||
import io.supertokens.thirdparty.ThirdParty; | ||
import io.supertokens.utils.SemVer; | ||
import io.supertokens.test.httpRequest.HttpResponseException; | ||
import org.junit.AfterClass; | ||
|
@@ -233,4 +237,42 @@ private static void checkUser(JsonObject resp, String userId, String email, Stri | |
assert (System.currentTimeMillis() - 10000 < user.get("timeJoined").getAsLong()); | ||
assertEquals(3, user.entrySet().size()); | ||
} | ||
|
||
@Test | ||
public void testGetUserForUsersOfOtherRecipeIds() throws Exception { | ||
String[] args = {"../"}; | ||
|
||
TestingProcessManager.TestingProcess process = TestingProcessManager.start(args); | ||
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED)); | ||
|
||
if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { | ||
return; | ||
} | ||
|
||
AuthRecipeUserInfo user1 = EmailPassword.signUp(process.getProcess(), "[email protected]", "password"); | ||
AuthRecipeUserInfo user2 = ThirdParty.signInUp(process.getProcess(), "google", "googleid", "[email protected]").user; | ||
|
||
{ | ||
HashMap<String, String> map = new HashMap<>(); | ||
map.put("userId", user1.getSupertokensUserId()); | ||
|
||
JsonObject response = HttpRequestForTesting.sendGETRequest(process.getProcess(), "", | ||
"http://localhost:3567/recipe/user", map, 1000, 1000, null, SemVer.v2_7.get(), | ||
"passwordless"); | ||
assertEquals(response.get("status").getAsString(), "UNKNOWN_USER_ID_ERROR"); | ||
} | ||
|
||
{ | ||
HashMap<String, String> map = new HashMap<>(); | ||
map.put("userId", user2.getSupertokensUserId()); | ||
|
||
JsonObject response = HttpRequestForTesting.sendGETRequest(process.getProcess(), "", | ||
"http://localhost:3567/recipe/user", map, 1000, 1000, null, SemVer.v2_7.get(), | ||
"passwordless"); | ||
assertEquals(response.get("status").getAsString(), "UNKNOWN_USER_ID_ERROR"); | ||
} | ||
|
||
process.kill(); | ||
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STOPPED)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,10 @@ | |
|
||
import com.google.gson.JsonObject; | ||
import io.supertokens.ProcessState; | ||
import io.supertokens.emailpassword.EmailPassword; | ||
import io.supertokens.passwordless.Passwordless; | ||
import io.supertokens.pluginInterface.STORAGE_TYPE; | ||
import io.supertokens.pluginInterface.authRecipe.AuthRecipeUserInfo; | ||
import io.supertokens.storageLayer.StorageLayer; | ||
import io.supertokens.test.TestingProcessManager; | ||
import io.supertokens.test.Utils; | ||
|
@@ -205,6 +208,46 @@ public void testAllTypesOfOutput() throws Exception { | |
} | ||
} | ||
|
||
@Test | ||
public void testGetUserForUsersOfOtherRecipeIds() throws Exception { | ||
String[] args = {"../"}; | ||
|
||
TestingProcessManager.TestingProcess process = TestingProcessManager.start(args); | ||
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED)); | ||
|
||
if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { | ||
return; | ||
} | ||
|
||
AuthRecipeUserInfo user1 = EmailPassword.signUp(process.getProcess(), "[email protected]", "password"); | ||
Passwordless.CreateCodeResponse user2code = Passwordless.createCode(process.getProcess(), "[email protected]", | ||
null, null, null); | ||
AuthRecipeUserInfo user2 = Passwordless.consumeCode(process.getProcess(), user2code.deviceId, user2code.deviceIdHash, user2code.userInputCode, null).user; | ||
|
||
{ | ||
HashMap<String, String> map = new HashMap<>(); | ||
map.put("userId", user1.getSupertokensUserId()); | ||
|
||
JsonObject response = HttpRequestForTesting.sendGETRequest(process.getProcess(), "", | ||
"http://localhost:3567/recipe/user", map, 1000, 1000, null, SemVer.v2_7.get(), | ||
"thirdparty"); | ||
assertEquals(response.get("status").getAsString(), "UNKNOWN_USER_ID_ERROR"); | ||
} | ||
|
||
{ | ||
HashMap<String, String> map = new HashMap<>(); | ||
map.put("userId", user2.getSupertokensUserId()); | ||
|
||
JsonObject response = HttpRequestForTesting.sendGETRequest(process.getProcess(), "", | ||
"http://localhost:3567/recipe/user", map, 1000, 1000, null, SemVer.v2_7.get(), | ||
"thirdparty"); | ||
assertEquals(response.get("status").getAsString(), "UNKNOWN_USER_ID_ERROR"); | ||
} | ||
|
||
process.kill(); | ||
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STOPPED)); | ||
} | ||
|
||
public static void checkUser(JsonObject user, String thirdPartyId, String thirdPartyUserId, String email) { | ||
assertNotNull(user.get("id")); | ||
assertNotNull(user.get("timeJoined")); | ||
|