Skip to content

Commit 6916388

Browse files
committed
2 parents 1cfb854 + 43a568e commit 6916388

File tree

11 files changed

+29
-31
lines changed

11 files changed

+29
-31
lines changed

.idea/.gitignore

-3
This file was deleted.

components/org.wso2.carbon.identity.authz.spicedb/pom.xml

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
~
1818
-->
1919

20-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2221
<modelVersion>4.0.0</modelVersion>
2322
<parent>
2423
<groupId>org.wso2.carbon.identity.authz.spicedb</groupId>
2524
<artifactId>identity-authz-spicedb</artifactId>
26-
<version>0.1.0-SNAPSHOT</version>
25+
<version>0.1.1-SNAPSHOT</version>
2726
<relativePath>../../pom.xml</relativePath>
2827
</parent>
2928
<packaging>bundle</packaging>
@@ -127,7 +126,7 @@
127126
<counter>COMPLEXITY</counter>
128127
<value>COVEREDRATIO</value>
129128
<!-- coverage to be increased to 0.8 in next PR -->
130-
<minimum>0.39</minimum>
129+
<minimum>0.38</minimum>
131130
</limit>
132131
</limits>
133132
</rule>

components/org.wso2.carbon.identity.authz.spicedb/src/main/java/org/wso2/carbon/identity/authz/spicedb/constants/SpiceDbModelConstants.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public class SpiceDbModelConstants {
6666
public static final String DETAILS = "details";
6767

6868
//Lookup request and response values
69-
public static final String LOOKED_AT = "lookedAt";
70-
public static final String RESOURCE_ID = "resourceId";
69+
public static final String LOOKED_AT = "lookedUpAt";
70+
public static final String RESOURCE_OBJECT_ID = "resourceObjectId";
7171
public static final String AFTER_RESULT_CURSOR = "afterResultCursor";
7272
public static final String OPTIONAL_LIMIT = "optionalLimit";
7373
public static final String OPTIONAL_SUBJECT_RELATION = "optionalSubjectRelation";

components/org.wso2.carbon.identity.authz.spicedb/src/main/java/org/wso2/carbon/identity/authz/spicedb/handler/model/LookupResourcesResult.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.wso2.carbon.identity.authz.spicedb.handler.model;
2020

21+
import com.google.gson.annotations.Expose;
2122
import com.google.gson.annotations.SerializedName;
2223
import org.wso2.carbon.identity.authz.spicedb.constants.SpiceDbModelConstants;
2324

@@ -28,6 +29,7 @@
2829
public class LookupResourcesResult {
2930

3031
@SerializedName(SpiceDbModelConstants.RESULT)
32+
@Expose
3133
private LookupResourcesResultBody lookupResourcesResultBody;
3234

3335
public LookupResourcesResultBody getLookupResourcesResult() {

components/org.wso2.carbon.identity.authz.spicedb/src/main/java/org/wso2/carbon/identity/authz/spicedb/handler/model/LookupResourcesResultBody.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class LookupResourcesResultBody {
3333
@SerializedName(SpiceDbModelConstants.LOOKED_AT)
3434
@Expose
3535
private ZedToken lookedAt;
36-
@SerializedName(SpiceDbModelConstants.RESOURCE_ID)
36+
@SerializedName(SpiceDbModelConstants.RESOURCE_OBJECT_ID)
3737
@Expose
3838
private String resourceId;
3939
@SerializedName(SpiceDbModelConstants.PERMISSION_RESULT)
@@ -44,7 +44,7 @@ public class LookupResourcesResultBody {
4444
private Map<String, Object> partialCaveatInfo;
4545
@SerializedName(SpiceDbModelConstants.AFTER_RESULT_CURSOR)
4646
@Expose
47-
private String afterResultCursor;
47+
private Map<String, Object> afterResultCursor;
4848

4949
public String lookedAt() {
5050

@@ -66,7 +66,7 @@ public Map<String, Object> getPartialCaveatInfo() {
6666
return partialCaveatInfo;
6767
}
6868

69-
public String getAfterResultCursor() {
69+
public Map<String, Object> getAfterResultCursor() {
7070

7171
return afterResultCursor;
7272
}

components/org.wso2.carbon.identity.authz.spicedb/src/main/java/org/wso2/carbon/identity/authz/spicedb/handler/model/LookupSubjectsResult.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.wso2.carbon.identity.authz.spicedb.handler.model;
2020

21+
import com.google.gson.annotations.Expose;
2122
import com.google.gson.annotations.SerializedName;
2223
import org.wso2.carbon.identity.authz.spicedb.constants.SpiceDbModelConstants;
2324

@@ -28,6 +29,7 @@
2829
public class LookupSubjectsResult {
2930

3031
@SerializedName(SpiceDbModelConstants.RESULT)
32+
@Expose
3133
private LookupSubjectsResultBody lookupSubjectsResultBody;
3234

3335
public LookupSubjectsResultBody getLookupSubjectsResult() {

components/org.wso2.carbon.identity.authz.spicedb/src/main/java/org/wso2/carbon/identity/authz/spicedb/handler/model/LookupSubjectsResultBody.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class LookupSubjectsResultBody {
4444
private Map<String, Object> partialCaveatInfo;
4545
@SerializedName(SpiceDbModelConstants.AFTER_RESULT_CURSOR)
4646
@Expose
47-
private String afterResultCursor;
47+
private Map<String, Object> afterResultCursor;
4848

4949
public String lookedAt() {
5050

@@ -66,7 +66,7 @@ public Map<String, Object> getPartialCaveatInfo() {
6666
return partialCaveatInfo;
6767
}
6868

69-
public String getAfterResultCursor() {
69+
public Map<String, Object> getAfterResultCursor() {
7070

7171
return afterResultCursor;
7272
}

components/org.wso2.carbon.identity.authz.spicedb/src/main/java/org/wso2/carbon/identity/authz/spicedb/handler/model/ReadRelationshipsResponse.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/**
2828
* The {@code ReadRelationshipsResponse} class represents the response of a read relationships request sent to SpiceDB.
2929
* The read results are returned as a stream of Json String objects. This class splits the stream and creates a list of
30-
* {@link ReadRelationshipsResult} objects.
30+
* {@link ReadRelationshipsResultBody} objects.
3131
*/
3232
public class ReadRelationshipsResponse {
3333

@@ -57,7 +57,7 @@ public ArrayList<ReadRelationshipsResult> getResults() {
5757
// public ReadAuthzDataResponse toAuthzDataReadResponse() {
5858
// ArrayList<ReadAuthzDataResult> authzDataReadResultObjects =
5959
// new ArrayList<>();
60-
// for (ReadRelationshipsResult readRelationshipsResult : results) {
60+
// for (ReadRelationshipsResultBody readRelationshipsResult : results) {
6161
// AuthorizationResource resourceObject = new AuthorizationResource(
6262
// readRelationshipsResult.getResourceType(),
6363
// readRelationshipsResult.getResourceId());
@@ -81,8 +81,9 @@ public ArrayList<ReadRelationshipsResult> getResults() {
8181
public SearchActionsResponse toSearchActionsResponse() {
8282

8383
ArrayList<AuthorizationAction> actionArrayList = new ArrayList<>();
84-
for (ReadRelationshipsResult readRelationshipsResult: results) {
85-
AuthorizationAction authorizationAction = new AuthorizationAction(readRelationshipsResult.getRelation());
84+
for (ReadRelationshipsResult readRelationshipsResultBody : results) {
85+
AuthorizationAction authorizationAction = new AuthorizationAction(readRelationshipsResultBody
86+
.getResultDetails().getRelation());
8687
actionArrayList.add(authorizationAction);
8788
}
8889
return new SearchActionsResponse(actionArrayList);
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
import java.util.Map;
2727

2828
/**
29-
* The {@code ReadRelationshipsResult} class represents the result item of a read relationships response returned by
30-
* SpiceDB.
29+
* The {@code ReadRelationshipsResultBody} class holds all the fields in a single element in a results stream in a
30+
* read relationships response returned by SpiceDB.
3131
*/
3232
@SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR",
33-
justification = "Field is populated via Gson deserialization")
34-
public class ReadRelationshipsResult {
33+
justification = "Fields are populated via Gson deserialization")
34+
public class ReadRelationshipsResultBody {
3535

3636
@SerializedName(SpiceDbModelConstants.READ_AT)
3737
@Expose
@@ -41,7 +41,7 @@ public class ReadRelationshipsResult {
4141
private Relationship relationship;
4242
@SerializedName(SpiceDbModelConstants.AFTER_RESULT_CURSOR)
4343
@Expose
44-
private String afterResultCursor;
44+
private Map<String, Object> afterResultCursor;
4545

4646
public String getReadAt () {
4747

@@ -83,7 +83,7 @@ public Map<String, Object> getOptionalCaveat () {
8383
return relationship.optionalCaveat;
8484
}
8585

86-
public String getAfterResultCursor () {
86+
public Map<String, Object> getAfterResultCursor() {
8787

8888
return afterResultCursor;
8989
}

components/org.wso2.carbon.identity.authz.spicedb/src/test/java/org/wso2/carbon/identity/authz/spicedb/handler/spicedb/SpicedbPermissionRequestServiceTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public void tearDown() {
9999
service = null;
100100
accessEvaluationRequest = null;
101101
bulkAccessEvaluationRequest = null;
102-
103102
}
104103

105104
@Test
@@ -128,7 +127,6 @@ public void testEvaluateForSuccessfulResponse() throws Exception {
128127
StatusLine statusLine = mock(StatusLine.class);
129128
when(mockedResponse.getStatusLine()).thenReturn(statusLine);
130129
when(statusLine.getStatusCode()).thenReturn(HttpStatus.SC_OK);
131-
132130
httpHandlerMock.when(() -> HttpHandler.sendPOSTRequest(
133131
SpiceDbApiConstants.PERMISSION_CHECK, REQUEST_BODY))
134132
.thenReturn(mockedResponse);
@@ -218,6 +216,7 @@ public void testEvaluateForUnknownErrorResponse() {
218216

219217
@Test
220218
public void testEvaluateForIOException() {
219+
221220
try (MockedStatic<HttpHandler> httpHandlerMock = Mockito.mockStatic(HttpHandler.class);
222221
MockedStatic<JsonUtil> jsonUtilMock = Mockito.mockStatic(JsonUtil.class)) {
223222

@@ -238,6 +237,7 @@ public void testEvaluateForIOException() {
238237

239238
@Test
240239
public void testEvaluateForURISyntaxException() {
240+
241241
try (MockedStatic<HttpHandler> httpHandlerMock = Mockito.mockStatic(HttpHandler.class);
242242
MockedStatic<JsonUtil> jsonUtilMock = Mockito.mockStatic(JsonUtil.class)) {
243243

@@ -322,7 +322,6 @@ public void testBulkEvaluateForErrorResponse() {
322322
StatusLine statusLine = mock(StatusLine.class);
323323
when(mockedResponse.getStatusLine()).thenReturn(statusLine);
324324
when(statusLine.getStatusCode()).thenReturn(HttpStatus.SC_BAD_REQUEST);
325-
326325
httpHandlerMock.when(() -> HttpHandler.sendPOSTRequest(
327326
SpiceDbApiConstants.PERMISSIONS_BULKCHECK, REQUEST_BODY))
328327
.thenReturn(mockedResponse);

pom.xml

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
~ under the License.
1818
-->
1919

20-
<project xmlns="http://maven.apache.org/POM/4.0.0"
21-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2321
<modelVersion>4.0.0</modelVersion>
2422

2523
<parent>
@@ -30,7 +28,7 @@
3028

3129
<groupId>org.wso2.carbon.identity.authz.spicedb</groupId>
3230
<artifactId>identity-authz-spicedb</artifactId>
33-
<version>0.1.0-SNAPSHOT</version>
31+
<version>0.1.1-SNAPSHOT</version>
3432
<packaging>pom</packaging>
3533

3634
<scm>

0 commit comments

Comments
 (0)