Search in sources :

Example 1 with AbstractNamingRequest

use of com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest in project nacos by alibaba.

the class NamingGrpcResourceParserTest method testParseWithFullContextForNamingRequest.

@Test
@Secured()
public void testParseWithFullContextForNamingRequest() throws NoSuchMethodException {
    Secured secured = getMethodSecure();
    AbstractNamingRequest request = mockNamingRequest("testNs", "testG", "testS");
    Resource actual = resourceParser.parse(request, secured);
    assertEquals("testNs", actual.getNamespaceId());
    assertEquals("testG", actual.getGroup());
    assertEquals("testS", actual.getName());
    assertEquals(Constants.Naming.NAMING_MODULE, actual.getType());
    assertEquals(MockNamingRequest.class.getSimpleName(), actual.getProperties().getProperty(com.alibaba.nacos.plugin.auth.constant.Constants.Resource.REQUEST_CLASS));
}
Also used : AbstractNamingRequest(com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest) Secured(com.alibaba.nacos.auth.annotation.Secured) Resource(com.alibaba.nacos.plugin.auth.api.Resource) Test(org.junit.Test) Secured(com.alibaba.nacos.auth.annotation.Secured)

Example 2 with AbstractNamingRequest

use of com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest in project nacos by alibaba.

the class GrpcProtocolAuthServiceTest method mockNamingRequest.

private void mockNamingRequest() {
    namingRequest = new AbstractNamingRequest() {
    };
    namingRequest.setNamespace("testNNs");
    namingRequest.setGroupName("testNG");
    namingRequest.setServiceName("testS");
}
Also used : AbstractNamingRequest(com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest)

Example 3 with AbstractNamingRequest

use of com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest in project nacos by alibaba.

the class NamingGrpcResourceParserTest method testParseWithoutNamespaceForNamingRequest.

@Test
@Secured()
public void testParseWithoutNamespaceForNamingRequest() throws NoSuchMethodException {
    Secured secured = getMethodSecure();
    AbstractNamingRequest request = mockNamingRequest(null, "testG", "testS");
    Resource actual = resourceParser.parse(request, secured);
    assertNull(actual.getNamespaceId());
    assertEquals("testG", actual.getGroup());
    assertEquals("testS", actual.getName());
    assertEquals(Constants.Naming.NAMING_MODULE, actual.getType());
    assertEquals(MockNamingRequest.class.getSimpleName(), actual.getProperties().getProperty(com.alibaba.nacos.plugin.auth.constant.Constants.Resource.REQUEST_CLASS));
}
Also used : AbstractNamingRequest(com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest) Secured(com.alibaba.nacos.auth.annotation.Secured) Resource(com.alibaba.nacos.plugin.auth.api.Resource) Test(org.junit.Test) Secured(com.alibaba.nacos.auth.annotation.Secured)

Example 4 with AbstractNamingRequest

use of com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest in project nacos by alibaba.

the class NamingGrpcResourceParserTest method testParseWithoutDataIdForNamingRequest.

@Test
@Secured()
public void testParseWithoutDataIdForNamingRequest() throws NoSuchMethodException {
    Secured secured = getMethodSecure();
    AbstractNamingRequest request = mockNamingRequest("testNs", "testG", null);
    Resource actual = resourceParser.parse(request, secured);
    assertEquals("testNs", actual.getNamespaceId());
    assertEquals("testG", actual.getGroup());
    assertEquals(StringUtils.EMPTY, actual.getName());
    assertEquals(Constants.Naming.NAMING_MODULE, actual.getType());
    assertEquals(MockNamingRequest.class.getSimpleName(), actual.getProperties().getProperty(com.alibaba.nacos.plugin.auth.constant.Constants.Resource.REQUEST_CLASS));
}
Also used : AbstractNamingRequest(com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest) Secured(com.alibaba.nacos.auth.annotation.Secured) Resource(com.alibaba.nacos.plugin.auth.api.Resource) Test(org.junit.Test) Secured(com.alibaba.nacos.auth.annotation.Secured)

Example 5 with AbstractNamingRequest

use of com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest in project nacos by alibaba.

the class NamingGrpcResourceParserTest method testParseWithoutGroupForNamingRequest.

@Test
@Secured()
public void testParseWithoutGroupForNamingRequest() throws NoSuchMethodException {
    Secured secured = getMethodSecure();
    AbstractNamingRequest request = mockNamingRequest("testNs", null, "testS");
    Resource actual = resourceParser.parse(request, secured);
    assertEquals("testNs", actual.getNamespaceId());
    assertEquals(StringUtils.EMPTY, actual.getGroup());
    assertEquals("testS", actual.getName());
    assertEquals(Constants.Naming.NAMING_MODULE, actual.getType());
    assertEquals(MockNamingRequest.class.getSimpleName(), actual.getProperties().getProperty(com.alibaba.nacos.plugin.auth.constant.Constants.Resource.REQUEST_CLASS));
}
Also used : AbstractNamingRequest(com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest) Secured(com.alibaba.nacos.auth.annotation.Secured) Resource(com.alibaba.nacos.plugin.auth.api.Resource) Test(org.junit.Test) Secured(com.alibaba.nacos.auth.annotation.Secured)

Aggregations

AbstractNamingRequest (com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest)7 Secured (com.alibaba.nacos.auth.annotation.Secured)4 Resource (com.alibaba.nacos.plugin.auth.api.Resource)4 Test (org.junit.Test)4 Request (com.alibaba.nacos.api.remote.request.Request)1 Response (com.alibaba.nacos.api.remote.response.Response)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1