Skip to content

Commit d1fd106

Browse files
authored
feat: expose AuthorizationService v2 (#287)
1 parent 3b1bb69 commit d1fd106

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

sdk/src/main/java/io/opentdf/platform/sdk/SDK.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public interface Services extends AutoCloseable {
7474

7575
AuthorizationServiceClientInterface authorization();
7676

77+
io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationV2();
78+
7779
KeyAccessServerRegistryServiceClientInterface kasRegistry();
7880

7981
WellKnownServiceClientInterface wellknown();

sdk/src/main/java/io/opentdf/platform/sdk/SDKBuilder.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ ServicesAndInternals buildServices() {
275275
var subjectMappingService = new SubjectMappingServiceClient(client);
276276
var resourceMappingService = new ResourceMappingServiceClient(client);
277277
var authorizationService = new AuthorizationServiceClient(client);
278+
var authorizationServiceV2 = new io.opentdf.platform.authorization.v2.AuthorizationServiceClient(client);
278279
var kasRegistryService = new KeyAccessServerRegistryServiceClient(client);
279280
var wellKnownService = new WellKnownServiceClient(client);
280281

@@ -311,6 +312,11 @@ public AuthorizationServiceClient authorization() {
311312
return authorizationService;
312313
}
313314

315+
@Override
316+
public io.opentdf.platform.authorization.v2.AuthorizationServiceClient authorizationV2() {
317+
return authorizationServiceV2;
318+
}
319+
314320
@Override
315321
public KeyAccessServerRegistryServiceClient kasRegistry() {
316322
return kasRegistryService;

sdk/src/test/java/io/opentdf/platform/sdk/FakeServices.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
public class FakeServices implements SDK.Services {
1414

1515
private final AuthorizationServiceClientInterface authorizationService;
16+
private final io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationServiceV2;
1617
private final AttributesServiceClientInterface attributesService;
1718
private final NamespaceServiceClientInterface namespaceService;
1819
private final SubjectMappingServiceClientInterface subjectMappingService;
@@ -23,6 +24,7 @@ public class FakeServices implements SDK.Services {
2324

2425
public FakeServices(
2526
AuthorizationServiceClientInterface authorizationService,
27+
io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationServiceV2,
2628
AttributesServiceClientInterface attributesService,
2729
NamespaceServiceClientInterface namespaceService,
2830
SubjectMappingServiceClientInterface subjectMappingService,
@@ -31,6 +33,7 @@ public FakeServices(
3133
WellKnownServiceClientInterface wellKnownServiceClient,
3234
SDK.KAS kas) {
3335
this.authorizationService = authorizationService;
36+
this.authorizationServiceV2 = authorizationServiceV2;
3437
this.attributesService = attributesService;
3538
this.namespaceService = namespaceService;
3639
this.subjectMappingService = subjectMappingService;
@@ -40,6 +43,11 @@ public FakeServices(
4043
this.kas = kas;
4144
}
4245

46+
@Override
47+
public io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationV2() {
48+
return Objects.requireNonNull(authorizationServiceV2);
49+
}
50+
4351
@Override
4452
public AuthorizationServiceClientInterface authorization() {
4553
return Objects.requireNonNull(authorizationService);

sdk/src/test/java/io/opentdf/platform/sdk/FakeServicesBuilder.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
public class FakeServicesBuilder {
1212
private AuthorizationServiceClientInterface authorizationService;
13+
private io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationServiceV2;
1314
private AttributesServiceClientInterface attributesService;
1415
private NamespaceServiceClientInterface namespaceService;
1516
private SubjectMappingServiceClientInterface subjectMappingService;
@@ -23,6 +24,11 @@ public FakeServicesBuilder setAuthorizationService(AuthorizationServiceClientInt
2324
return this;
2425
}
2526

27+
public FakeServicesBuilder setAuthorizationServiceV2(io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationServiceV2) {
28+
this.authorizationServiceV2 = authorizationServiceV2;
29+
return this;
30+
}
31+
2632
public FakeServicesBuilder setAttributesService(AttributesServiceClientInterface attributesService) {
2733
this.attributesService = attributesService;
2834
return this;
@@ -59,7 +65,7 @@ public FakeServicesBuilder setKas(SDK.KAS kas) {
5965
}
6066

6167
public FakeServices build() {
62-
return new FakeServices(authorizationService, attributesService, namespaceService, subjectMappingService,
68+
return new FakeServices(authorizationService, authorizationServiceV2, attributesService, namespaceService, subjectMappingService,
6369
resourceMappingService, keyAccessServerRegistryServiceFutureStub, wellKnownServiceClient, kas);
6470
}
6571
}

sdk/src/test/java/io/opentdf/platform/sdk/SDKBuilderTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, Re
268268
services = servicesAndComponents.services;
269269

270270
assertThat(services).isNotNull();
271+
io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationServiceClientInterface
272+
= services.authorizationV2();
273+
assertThat(authorizationServiceClientInterface).isNotNull();
271274

272275
httpServer.enqueue(new MockResponse()
273276
.setBody("{\"access_token\": \"hereisthetoken\", \"token_type\": \"Bearer\"}")

sdk/src/test/java/io/opentdf/platform/sdk/SDKTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ void testReadingProtocolClient() {
3030
assertThat(sdk.getPlatformServicesClient()).isSameAs(platformServicesClient);
3131
}
3232

33+
@Test
34+
void testAuthorizationServiceClientV2() {
35+
var platformServicesClient = mock(ProtocolClient.class);
36+
io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authSvcV2 = mock(io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface.class);
37+
var fakeServiceBuilder = new FakeServicesBuilder().setAuthorizationServiceV2(authSvcV2).build();
38+
var sdk = new SDK(fakeServiceBuilder, null, null, platformServicesClient, null);
39+
assertThat(sdk.getServices().authorizationV2()).isSameAs(fakeServiceBuilder.authorizationV2());
40+
}
41+
3342
@Test
3443
void testExaminingInvalidFile() {
3544
var chan = new SeekableByteChannel() {

0 commit comments

Comments
 (0)