-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change loginAs to return UserLoginResponse
add apiUrl to config
- Loading branch information
Showing
4 changed files
with
61 additions
and
14 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
11 changes: 11 additions & 0 deletions
11
src/main/java/io/permit/sdk/api/models/UserLoginResponse.java
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.permit.sdk.api.models; | ||
|
||
import java.util.Map; | ||
|
||
public class UserLoginResponse { | ||
public String error = null; | ||
public String token = null; | ||
public String extra = null; | ||
public String redirectUrl = null; | ||
public Map<String, String> content = null; | ||
} |
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 |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
import com.google.common.base.Strings; | ||
import com.google.gson.Gson; | ||
import io.permit.sdk.api.PermitApiException; | ||
import io.permit.sdk.api.models.UserLoginResponse; | ||
import io.permit.sdk.api.models.UserModel; | ||
import io.permit.sdk.enforcement.AssignedRole; | ||
import io.permit.sdk.enforcement.Resource; | ||
import io.permit.sdk.enforcement.User; | ||
import okhttp3.HttpUrl; | ||
|
@@ -15,7 +15,7 @@ | |
import java.io.IOException; | ||
import java.net.InetSocketAddress; | ||
import java.net.Socket; | ||
import java.util.ArrayList; | ||
import java.util.Random; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
|
@@ -32,9 +32,12 @@ class PermitIntegrationTests { | |
private final static int loggerSeparatorLength = 80; | ||
private boolean skipTests = false; | ||
|
||
static Random rand = new Random(); | ||
static String suffixedUserKey = "test|" + rand.nextInt(); | ||
|
||
private final static String roleKey = "captain"; | ||
private final static String tenantKey = "tortuga"; | ||
private final static String userKey = "test|13d4dd3ff127"; | ||
private final static String userKey = suffixedUserKey; | ||
private final static String userEmail = "[email protected]"; | ||
private final static String userFirstName = "Jack"; | ||
private final static String userLastName = "Sparrow"; | ||
|
@@ -90,7 +93,7 @@ private static void logTestIsStarting(String testName) { | |
Boolean allowed = null; | ||
try { | ||
allowed = permit.check( | ||
User.fromString("55de594980944d48944dc10b9c70483c"), | ||
User.fromString(userKey), | ||
"create", | ||
Resource.fromString("document") | ||
); | ||
|
@@ -101,6 +104,25 @@ private static void logTestIsStarting(String testName) { | |
assertTrue(allowed, "permit.check() should be true"); | ||
} | ||
|
||
@Test void testPermitElementsLoginAs() { | ||
if (skipTests) { | ||
return; | ||
} | ||
logTestIsStarting("permitCheckSucceeds"); | ||
Permit permit = new Permit(this.config); | ||
UserLoginResponse loginAs = null; | ||
try { | ||
loginAs = permit.elements.loginAs("[email protected]", "fafb66f9c98647ad954f129b9f2b1c84"); | ||
} catch (IOException e) { | ||
fail(e); | ||
} catch (PermitApiException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
assertNotNull(loginAs.redirectUrl); | ||
assertNotNull(loginAs.content); | ||
} | ||
|
||
@Test void testPermitApiUserLifecycle() { | ||
if (skipTests) { | ||
return; | ||
|