use of io.envoyproxy.envoy.config.route.v3.HeaderMatcher in project grpc-java by grpc.
the class RbacFilterTest method headerParser.
@Test
@SuppressWarnings({ "unchecked", "deprecation" })
public void headerParser() {
HeaderMatcher headerMatcher = HeaderMatcher.newBuilder().setName("party").setExactMatch("win").build();
List<Permission> permissionList = Arrays.asList(Permission.newBuilder().setHeader(headerMatcher).build());
List<Principal> principalList = Arrays.asList(Principal.newBuilder().setHeader(headerMatcher).build());
ConfigOrError<RbacConfig> result = parseOverride(permissionList, principalList);
assertThat(result.errorDetail).isNull();
ServerCall<Void, Void> serverCall = mock(ServerCall.class);
GrpcAuthorizationEngine engine = new GrpcAuthorizationEngine(result.config.authConfig());
AuthDecision decision = engine.evaluate(metadata("party", "win"), serverCall);
assertThat(decision.decision()).isEqualTo(GrpcAuthorizationEngine.Action.DENY);
}
use of io.envoyproxy.envoy.config.route.v3.HeaderMatcher in project grpc-java by grpc.
the class RbacFilterTest method headerParser_headerName.
@Test
@SuppressWarnings("deprecation")
public void headerParser_headerName() {
HeaderMatcher headerMatcher = HeaderMatcher.newBuilder().setName("grpc--feature").setExactMatch("win").build();
List<Permission> permissionList = Arrays.asList(Permission.newBuilder().setHeader(headerMatcher).build());
HeaderMatcher headerMatcher2 = HeaderMatcher.newBuilder().setName(":scheme").setExactMatch("win").build();
List<Principal> principalList = Arrays.asList(Principal.newBuilder().setHeader(headerMatcher2).build());
ConfigOrError<RbacConfig> result = parseOverride(permissionList, principalList);
assertThat(result.errorDetail).isNotNull();
}
Aggregations