Search in sources :

Example 6 with USER_ID

use of oap.ws.Interceptor.USER_ID in project oap by oaplatform.

the class SecurityInterceptor2Test method testPostProcessing.

@Test
public void testPostProcessing() {
    when(mockAclService.checkAll("1", "testUser")).thenReturn(asList("test1.read"));
    final Session session = new Session();
    session.set(USER_ID, "testUser");
    val methodWithAnnotation = REFLECTION.method(method -> method.name().equals("methodWithAnnotation")).get();
    val op = (ObjectWithPermissions) securityInterceptor.postProcessing(new TestAPI.Res("1"), session, methodWithAnnotation);
    assertThat(op.permissions).containsExactlyInAnyOrder("test1.read");
}
Also used : lombok.val(lombok.val) DateTimeUtils(org.joda.time.DateTimeUtils) Reflection(oap.reflect.Reflection) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.testng.annotations.Test) Collections.singletonList(java.util.Collections.singletonList) Reflect(oap.reflect.Reflect) InetAddress(java.net.InetAddress) Arrays.asList(java.util.Arrays.asList) USER_ID(oap.ws.Interceptor.USER_ID) Session(oap.http.Session) MockRequest(oap.http.testng.MockRequest) AclService(oap.security.acl.AclService) Id(oap.util.Id) Context(oap.http.Context) WsParam(oap.ws.WsParam) lombok.val(lombok.val) UUID(java.util.UUID) Mockito.when(org.mockito.Mockito.when) UnknownHostException(java.net.UnknownHostException) Request(oap.http.Request) List(java.util.List) HttpGet(org.apache.http.client.methods.HttpGet) Optional(java.util.Optional) Protocol(oap.http.Protocol) Mockito.mock(org.mockito.Mockito.mock) Session(oap.http.Session) Test(org.testng.annotations.Test)

Aggregations

InetAddress (java.net.InetAddress)6 UnknownHostException (java.net.UnknownHostException)6 Arrays.asList (java.util.Arrays.asList)6 Collections.singletonList (java.util.Collections.singletonList)6 List (java.util.List)6 Optional (java.util.Optional)6 UUID (java.util.UUID)6 lombok.val (lombok.val)6 Context (oap.http.Context)6 Protocol (oap.http.Protocol)6 Request (oap.http.Request)6 Session (oap.http.Session)6 MockRequest (oap.http.testng.MockRequest)6 Reflect (oap.reflect.Reflect)6 Reflection (oap.reflect.Reflection)6 AclService (oap.security.acl.AclService)6 Id (oap.util.Id)6 USER_ID (oap.ws.Interceptor.USER_ID)6 WsParam (oap.ws.WsParam)6 HttpGet (org.apache.http.client.methods.HttpGet)6