Search in sources :

Example 46 with ApiMethodConfig

use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.

the class ApiAnnotationConfigTest method testSetScopesIfSpecified_empty.

@Test
public void testSetScopesIfSpecified_empty() throws Exception {
    String[] empty = {};
    annotationConfig.setScopesIfSpecified(empty);
    EndpointMethod method = getResultNoParamsMethod();
    ApiMethodConfig methodConfig = config.getApiClassConfig().getMethods().getOrCreate(method);
    assertEquals(toScopeExpression(), methodConfig.getScopeExpression());
    String[] scopes = { "bleh", "more bleh" };
    annotationConfig.setScopesIfSpecified(scopes);
    annotationConfig.setScopesIfSpecified(empty);
    assertEquals(toScopeExpression(), config.getScopeExpression());
}
Also used : ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) EndpointMethod(com.google.api.server.spi.EndpointMethod) Test(org.junit.Test)

Example 47 with ApiMethodConfig

use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.

the class ApiAnnotationConfigTest method testSetClientIdsIfSpecified_empty.

@Test
public void testSetClientIdsIfSpecified_empty() throws Exception {
    String[] empty = {};
    annotationConfig.setClientIdsIfSpecified(empty);
    EndpointMethod method = getResultNoParamsMethod();
    ApiMethodConfig methodConfig = config.getApiClassConfig().getMethods().getOrCreate(method);
    assertEquals(Collections.emptyList(), methodConfig.getClientIds());
    String[] clientIds = { "bleh", "more bleh" };
    annotationConfig.setClientIdsIfSpecified(clientIds);
    annotationConfig.setClientIdsIfSpecified(empty);
    assertEquals(Collections.emptyList(), config.getClientIds());
}
Also used : ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) EndpointMethod(com.google.api.server.spi.EndpointMethod) Test(org.junit.Test)

Example 48 with ApiMethodConfig

use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.

the class ApiAnnotationConfigTest method testSetClientIdsIfSpecified.

@Test
public void testSetClientIdsIfSpecified() throws Exception {
    String[] clientIds = { "foo", "bar" };
    annotationConfig.setClientIdsIfSpecified(clientIds);
    assertEquals(Arrays.asList(clientIds), config.getClientIds());
    ApiMethodConfig methodConfig = config.getApiClassConfig().getMethods().getOrCreate(getResultNoParamsMethod());
    assertEquals(Arrays.asList(clientIds), methodConfig.getClientIds());
}
Also used : ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) Test(org.junit.Test)

Example 49 with ApiMethodConfig

use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.

the class ApiConfigAnnotationReaderTest method testEndpointWithBridgeMethods.

@Test
public void testEndpointWithBridgeMethods() throws Exception {
    ApiConfig config = createConfig(BridgeInheritanceEndpoint.class);
    annotationReader.loadEndpointClass(serviceContext, BridgeInheritanceEndpoint.class, config);
    annotationReader.loadEndpointMethods(serviceContext, BridgeInheritanceEndpoint.class, config.getApiClassConfig().getMethods());
    assertEquals(2, config.getApiClassConfig().getMethods().size());
    ApiMethodConfig fn1 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(BridgeInheritanceEndpoint.class.getMethod("fn1")));
    validateMethod(fn1, "api6.foos.fn1", "fn1", ApiMethod.HttpMethod.GET, DEFAULT_SCOPES, DEFAULT_AUDIENCES, DEFAULT_CLIENTIDS, null, null);
    ApiMethodConfig fn2 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(BridgeInheritanceEndpoint.class.getSuperclass().getMethod("fn2")));
    validateMethod(fn2, "api6.foos.fn2", "fn2", ApiMethod.HttpMethod.GET, DEFAULT_SCOPES, DEFAULT_AUDIENCES, DEFAULT_CLIENTIDS, null, null);
    ApiMethodConfig bridge = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(BridgeInheritanceEndpoint.class.getSuperclass().getMethod("fn1")));
    assertNull(bridge);
}
Also used : ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) BridgeInheritanceEndpoint(com.google.api.server.spi.testing.BridgeInheritanceEndpoint) Test(org.junit.Test)

Example 50 with ApiMethodConfig

use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.

the class ApiConfigAnnotationReaderTest method testSimpleOverrideEndpoint.

@Test
public void testSimpleOverrideEndpoint() throws Exception {
    ApiConfig config = createConfig(SimpleOverrideEndpoint.class);
    annotationReader.loadEndpointClass(serviceContext, SimpleOverrideEndpoint.class, config);
    annotationReader.loadEndpointMethods(serviceContext, SimpleOverrideEndpoint.class, config.getApiClassConfig().getMethods());
    assertEquals(1, config.getApiClassConfig().getMethods().size());
    ApiMethodConfig foo = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(SimpleOverrideEndpoint.class.getMethod("foo", String.class)));
    validateMethod(foo, "api.foos.fn", "fn", ApiMethod.HttpMethod.GET, DEFAULT_SCOPES, DEFAULT_AUDIENCES, DEFAULT_CLIENTIDS, null, null);
}
Also used : ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Aggregations

ApiMethodConfig (com.google.api.server.spi.config.model.ApiMethodConfig)54 Test (org.junit.Test)37 ApiConfig (com.google.api.server.spi.config.model.ApiConfig)26 EndpointMethod (com.google.api.server.spi.EndpointMethod)16 SimpleLevelOverridingInheritedApi (com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi)10 Api (com.google.api.server.spi.config.Api)8 SimpleLevelOverridingApi (com.google.api.server.spi.testing.SimpleLevelOverridingApi)8 User (com.google.api.server.spi.auth.common.User)5 PassAuthenticator (com.google.api.server.spi.testing.PassAuthenticator)5 PassPeerAuthenticator (com.google.api.server.spi.testing.PassPeerAuthenticator)5 ApiParameterConfig (com.google.api.server.spi.config.model.ApiParameterConfig)4 ApiAuthConfig (com.google.api.server.spi.config.model.ApiAuthConfig)3 ApiCacheControlConfig (com.google.api.server.spi.config.model.ApiCacheControlConfig)3 ApiFrontendLimitsConfig (com.google.api.server.spi.config.model.ApiFrontendLimitsConfig)3 Attribute (com.google.api.server.spi.request.Attribute)3 Named (com.google.api.server.spi.config.Named)2 ApiSerializationConfig (com.google.api.server.spi.config.model.ApiSerializationConfig)2 UnauthorizedException (com.google.api.server.spi.response.UnauthorizedException)2 FailAuthenticator (com.google.api.server.spi.testing.FailAuthenticator)2 FailPeerAuthenticator (com.google.api.server.spi.testing.FailPeerAuthenticator)2