Skip to content
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
2 changes: 2 additions & 0 deletions sdk/src/main/java/io/opentdf/platform/sdk/SDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public interface Services extends AutoCloseable {

AuthorizationServiceClientInterface authorization();

io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationV2();

KeyAccessServerRegistryServiceClientInterface kasRegistry();

WellKnownServiceClientInterface wellknown();
Expand Down
6 changes: 6 additions & 0 deletions sdk/src/main/java/io/opentdf/platform/sdk/SDKBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ ServicesAndInternals buildServices() {
var subjectMappingService = new SubjectMappingServiceClient(client);
var resourceMappingService = new ResourceMappingServiceClient(client);
var authorizationService = new AuthorizationServiceClient(client);
var authorizationServiceV2 = new io.opentdf.platform.authorization.v2.AuthorizationServiceClient(client);
var kasRegistryService = new KeyAccessServerRegistryServiceClient(client);
var wellKnownService = new WellKnownServiceClient(client);

Expand Down Expand Up @@ -311,6 +312,11 @@ public AuthorizationServiceClient authorization() {
return authorizationService;
}

@Override
public io.opentdf.platform.authorization.v2.AuthorizationServiceClient authorizationV2() {
return authorizationServiceV2;
}

@Override
public KeyAccessServerRegistryServiceClient kasRegistry() {
return kasRegistryService;
Expand Down
8 changes: 8 additions & 0 deletions sdk/src/test/java/io/opentdf/platform/sdk/FakeServices.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
public class FakeServices implements SDK.Services {

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

public FakeServices(
AuthorizationServiceClientInterface authorizationService,
io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationServiceV2,
AttributesServiceClientInterface attributesService,
NamespaceServiceClientInterface namespaceService,
SubjectMappingServiceClientInterface subjectMappingService,
Expand All @@ -31,6 +33,7 @@ public FakeServices(
WellKnownServiceClientInterface wellKnownServiceClient,
SDK.KAS kas) {
this.authorizationService = authorizationService;
this.authorizationServiceV2 = authorizationServiceV2;
this.attributesService = attributesService;
this.namespaceService = namespaceService;
this.subjectMappingService = subjectMappingService;
Expand All @@ -40,6 +43,11 @@ public FakeServices(
this.kas = kas;
}

@Override
public io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationV2() {
return Objects.requireNonNull(authorizationServiceV2);
}

@Override
public AuthorizationServiceClientInterface authorization() {
return Objects.requireNonNull(authorizationService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

public class FakeServicesBuilder {
private AuthorizationServiceClientInterface authorizationService;
private io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationServiceV2;
private AttributesServiceClientInterface attributesService;
private NamespaceServiceClientInterface namespaceService;
private SubjectMappingServiceClientInterface subjectMappingService;
Expand All @@ -23,6 +24,11 @@ public FakeServicesBuilder setAuthorizationService(AuthorizationServiceClientInt
return this;
}

public FakeServicesBuilder setAuthorizationServiceV2(io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationServiceV2) {
this.authorizationServiceV2 = authorizationServiceV2;
return this;
}

public FakeServicesBuilder setAttributesService(AttributesServiceClientInterface attributesService) {
this.attributesService = attributesService;
return this;
Expand Down Expand Up @@ -59,7 +65,7 @@ public FakeServicesBuilder setKas(SDK.KAS kas) {
}

public FakeServices build() {
return new FakeServices(authorizationService, attributesService, namespaceService, subjectMappingService,
return new FakeServices(authorizationService, authorizationServiceV2, attributesService, namespaceService, subjectMappingService,
resourceMappingService, keyAccessServerRegistryServiceFutureStub, wellKnownServiceClient, kas);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, Re
services = servicesAndComponents.services;

assertThat(services).isNotNull();
io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authorizationServiceClientInterface
= services.authorizationV2();
assertThat(authorizationServiceClientInterface).isNotNull();

httpServer.enqueue(new MockResponse()
.setBody("{\"access_token\": \"hereisthetoken\", \"token_type\": \"Bearer\"}")
Expand Down
9 changes: 9 additions & 0 deletions sdk/src/test/java/io/opentdf/platform/sdk/SDKTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ void testReadingProtocolClient() {
assertThat(sdk.getPlatformServicesClient()).isSameAs(platformServicesClient);
}

@Test
void testAuthorizationServiceClientV2() {
var platformServicesClient = mock(ProtocolClient.class);
io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface authSvcV2 = mock(io.opentdf.platform.authorization.v2.AuthorizationServiceClientInterface.class);
var fakeServiceBuilder = new FakeServicesBuilder().setAuthorizationServiceV2(authSvcV2).build();
var sdk = new SDK(fakeServiceBuilder, null, null, platformServicesClient, null);
assertThat(sdk.getServices().authorizationV2()).isSameAs(fakeServiceBuilder.authorizationV2());
}

@Test
void testExaminingInvalidFile() {
var chan = new SeekableByteChannel() {
Expand Down
Loading