use of com.alibaba.nacos.auth.annotation.Secured 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));
}
use of com.alibaba.nacos.auth.annotation.Secured in project nacos by alibaba.
the class NamingGrpcResourceParserTest method testParseWithoutGroupForOtherRequest.
@Test
@Secured()
public void testParseWithoutGroupForOtherRequest() throws NoSuchMethodException {
Secured secured = getMethodSecure();
Request request = mockOtherRequest("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(NotifySubscriberRequest.class.getSimpleName(), actual.getProperties().getProperty(com.alibaba.nacos.plugin.auth.constant.Constants.Resource.REQUEST_CLASS));
}
use of com.alibaba.nacos.auth.annotation.Secured in project nacos by alibaba.
the class NamingGrpcResourceParserTest method testParseWithoutNamespaceForOtherRequest.
@Test
@Secured()
public void testParseWithoutNamespaceForOtherRequest() throws NoSuchMethodException {
Secured secured = getMethodSecure();
Request request = mockOtherRequest(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(NotifySubscriberRequest.class.getSimpleName(), actual.getProperties().getProperty(com.alibaba.nacos.plugin.auth.constant.Constants.Resource.REQUEST_CLASS));
}
use of com.alibaba.nacos.auth.annotation.Secured in project nacos by alibaba.
the class ConfigHttpResourceParserTest method testParseWithoutDataId.
@Test
@Secured(signType = Constants.Config.CONFIG_MODULE)
public void testParseWithoutDataId() throws NoSuchMethodException {
Secured secured = getMethodSecure();
Mockito.when(request.getParameter(eq("tenant"))).thenReturn("testNs");
Mockito.when(request.getParameter(eq(Constants.GROUP))).thenReturn("testG");
Resource actual = resourceParser.parse(request, secured);
assertEquals("testNs", actual.getNamespaceId());
assertEquals("testG", actual.getGroup());
assertEquals(StringUtils.EMPTY, actual.getName());
assertEquals(Constants.Config.CONFIG_MODULE, actual.getType());
}
use of com.alibaba.nacos.auth.annotation.Secured in project nacos by alibaba.
the class ConfigHttpResourceParserTest method testParseWithoutNamespace.
@Test
@Secured(signType = Constants.Config.CONFIG_MODULE)
public void testParseWithoutNamespace() throws NoSuchMethodException {
Secured secured = getMethodSecure();
Mockito.when(request.getParameter(eq(Constants.GROUP))).thenReturn("testG");
Mockito.when(request.getParameter(eq(Constants.DATAID))).thenReturn("testD");
Resource actual = resourceParser.parse(request, secured);
assertEquals(StringUtils.EMPTY, actual.getNamespaceId());
assertEquals("testG", actual.getGroup());
assertEquals("testD", actual.getName());
assertEquals(Constants.Config.CONFIG_MODULE, actual.getType());
}
Aggregations