Skip to content

Commit

Permalink
fix sdk
Browse files Browse the repository at this point in the history
Signed-off-by: pyalex <[email protected]>
  • Loading branch information
pyalex committed Nov 12, 2021
1 parent 1201533 commit bf86ebb
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions java/sdk/java/src/test/java/com/gojek/feast/FeastClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static org.mockito.Mockito.mock;

import com.google.protobuf.Timestamp;
import feast.common.auth.credentials.JwtCallCredentials;
import feast.proto.serving.ServingAPIProto.FeatureReferenceV2;
import feast.proto.serving.ServingAPIProto.GetOnlineFeaturesRequestV2;
import feast.proto.serving.ServingAPIProto.GetOnlineFeaturesRequestV2.EntityRow;
Expand All @@ -31,7 +30,6 @@
import feast.proto.serving.ServingServiceGrpc.ServingServiceImplBase;
import feast.proto.types.ValueProto.Value;
import io.grpc.*;
import io.grpc.ServerCall.Listener;
import io.grpc.inprocess.InProcessChannelBuilder;
import io.grpc.inprocess.InProcessServerBuilder;
import io.grpc.stub.StreamObserver;
Expand Down Expand Up @@ -70,24 +68,7 @@ public void getOnlineFeaturesV2(
}
}));

// Mock Authentication interceptor will flag authenticated request by setting isAuthenticated to
// true.
private ServerInterceptor mockAuthInterceptor =
new ServerInterceptor() {
@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(
ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
final Metadata.Key<String> authorizationKey =
Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER);
if (headers.containsKey(authorizationKey)) {
isAuthenticated.set(true);
}
return next.startCall(call, headers);
}
};

private FeastClient client;
private FeastClient authenticatedClient;

@Before
public void setup() throws Exception {
Expand All @@ -99,7 +80,6 @@ public void setup() throws Exception {
InProcessServerBuilder.forName(serverName)
.directExecutor()
.addService(this.servingMock)
.intercept(mockAuthInterceptor)
.build()
.start());

Expand All @@ -108,22 +88,13 @@ public void setup() throws Exception {
this.grpcRule.register(
InProcessChannelBuilder.forName(serverName).directExecutor().build());
this.client = new FeastClient(channel, Optional.empty());
this.authenticatedClient =
new FeastClient(channel, Optional.of(new JwtCallCredentials(AUTH_TOKEN)));
}

@Test
public void shouldGetOnlineFeatures() {
shouldGetOnlineFeaturesWithClient(this.client);
}

@Test
public void shouldAuthenticateAndGetOnlineFeatures() {
isAuthenticated.set(false);
shouldGetOnlineFeaturesWithClient(this.authenticatedClient);
assertEquals(isAuthenticated.get(), true);
}

private void shouldGetOnlineFeaturesWithClient(FeastClient client) {
List<Row> rows =
client.getOnlineFeatures(
Expand Down

0 comments on commit bf86ebb

Please sign in to comment.