use of com.google.api.server.spi.config.AuthLevel in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testSimpleLevelOverriding.
@Test
public void testSimpleLevelOverriding() throws Exception {
String apiConfigSource = g.generateConfig(SimpleLevelOverridingApi.class).get("myapi-v1.api");
JsonNode root = objectMapper.readValue(apiConfigSource, JsonNode.class);
JsonNode methods = root.path("methods");
// myapi.resource1.noOverrides
JsonNode noOverrides = methods.path("myapi.resource1.noOverrides");
assertFalse(noOverrides.isMissingNode());
verifyStrings(objectMapper.convertValue(noOverrides.path("scopes"), String[].class), new String[] { "s0a", "s1a" });
verifyStrings(objectMapper.convertValue(noOverrides.path("audiences"), String[].class), new String[] { "a0a", "a1a" });
verifyStrings(objectMapper.convertValue(noOverrides.path("clientIds"), String[].class), new String[] { "c0a", "c1a" });
assertEquals("resource1", objectMapper.convertValue(noOverrides.path("path"), String.class));
assertEquals(AuthLevel.REQUIRED, objectMapper.convertValue(noOverrides.path("authLevel"), AuthLevel.class));
// myapi.resource1.overrides
JsonNode overrides = methods.path("myapi.resource1.overrides");
assertFalse(overrides.isMissingNode());
verifyStrings(objectMapper.convertValue(overrides.path("scopes"), String[].class), new String[] { "s0b", "s1b" });
verifyStrings(objectMapper.convertValue(overrides.path("audiences"), String[].class), new String[] { "a0b", "a1b" });
verifyStrings(objectMapper.convertValue(overrides.path("clientIds"), String[].class), new String[] { "c0b", "c1b" });
assertEquals("overridden", objectMapper.convertValue(overrides.path("path"), String.class));
assertEquals(AuthLevel.OPTIONAL, objectMapper.convertValue(overrides.path("authLevel"), AuthLevel.class));
}
use of com.google.api.server.spi.config.AuthLevel in project endpoints-java by cloudendpoints.
the class ApiClassAnnotationConfigTest method testSetAuthLevelIfSpecified.
@Test
public void testSetAuthLevelIfSpecified() throws Exception {
for (AuthLevel authLevel : AuthLevel.values()) {
if (authLevel == AuthLevel.UNSPECIFIED) {
// next test.
continue;
}
annotationConfig.setAuthLevelIfSpecified(authLevel);
Mockito.verify(config).setAuthLevel(authLevel);
}
}
use of com.google.api.server.spi.config.AuthLevel in project endpoints-java by cloudendpoints.
the class ApiAnnotationConfigTest method testSetAuthLevelIfSpecified.
@Test
public void testSetAuthLevelIfSpecified() throws Exception {
for (AuthLevel authLevel : AuthLevel.values()) {
if (authLevel == AuthLevel.UNSPECIFIED) {
// next test.
continue;
}
annotationConfig.setAuthLevelIfSpecified(authLevel);
assertEquals(authLevel, config.getAuthLevel());
ApiMethodConfig methodConfig = config.getApiClassConfig().getMethods().getOrCreate(getResultNoParamsMethod());
assertEquals(authLevel, methodConfig.getAuthLevel());
}
}
use of com.google.api.server.spi.config.AuthLevel in project endpoints-java by cloudendpoints.
the class ApiMethodAnnotationConfigTest method testSetAuthLevelIfSpecified.
@Test
public void testSetAuthLevelIfSpecified() throws Exception {
for (AuthLevel authLevel : AuthLevel.values()) {
if (authLevel == AuthLevel.UNSPECIFIED) {
// next test.
continue;
}
annotationConfig.setAuthLevelIfSpecified(authLevel);
assertEquals(authLevel, config.getAuthLevel());
}
}
Aggregations