### Question:
AdminOnlyAuthzModule extends SSOTokenAuthzModule { protected boolean isSuperUser(String userId) { return sessionService.get().isSuperUser(userId); } @Inject  AdminOnlyAuthzModule(Config<SessionService> sessionService, @Named("frRest") Debug debug); @Override String getName(); static final String NAME; }### Answer:
@Test public void shouldAuthorizeValidContext() throws Exception { SSOTokenContext mockSSOTokenContext = mock(SSOTokenContext.class); SSOToken mockSSOToken = mock(SSOToken.class); given(mockSSOTokenContext.getCallerSSOToken()).willReturn(mockSSOToken); given(mockSSOToken.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("test"); given(mockService.isSuperUser("test")).willReturn(true); Promise<AuthorizationResult, ResourceException> result = testModule.authorize(mockSSOTokenContext); assertTrue(result.get().isAuthorized()); }
@Test public void shouldFailNonSuperUser() throws Exception { SSOTokenContext mockSSOTokenContext = mock(SSOTokenContext.class); SSOToken mockSSOToken = mock(SSOToken.class); given(mockSSOTokenContext.getCallerSSOToken()).willReturn(mockSSOToken); given(mockSSOToken.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("test"); given(mockService.isSuperUser("test")).willReturn(false); Promise<AuthorizationResult, ResourceException> result = testModule.authorize(mockSSOTokenContext); assertFalse(result.get().isAuthorized()); }