### Question:
ElevatedConnectionFactoryWrapper implements ConnectionFactory { @Override public Connection getConnection() throws ResourceException { Connection connection = connectionFactory.getConnection(); SSOToken ssoToken = ssoTokenPrivilegedAction.run(); return new ElevatedConnection(connection, ssoToken); } @Inject  ElevatedConnectionFactoryWrapper(ConnectionFactory connectionFactory,
            PrivilegedAction<SSOToken> ssoTokenPrivilegedAction); @Override Connection getConnection(); @Override Promise<Connection, ResourceException> getConnectionAsync(); @Override void close();  }### Answer:
@Test public void requestGetsElevatedToAdminSession() throws Exception { SSOToken ssoToken = mock(SSOToken.class); given(ssoTokenPrivilegedAction.run()).willReturn(ssoToken); SSOPrincipal principal = new SSOPrincipal("test"); given(ssoToken.getPrincipal()).willReturn(principal); SSOTokenID tokenID = mock(SSOTokenID.class); given(ssoToken.getTokenID()).willReturn(tokenID); given(internalConnectionFactory.getConnection()).willReturn(connection); RootContext context = new RootContext(); ReadRequest readRequest = Requests.newReadRequest("/test", "abc"); try (Connection connection = connectionFactory.getConnection()) { connection.read(context, readRequest); } verify(connection).read(contextCaptor.capture(), eq(readRequest)); Context capturedContext = contextCaptor.getValue(); assertThat(capturedContext.containsContext(SecurityContext.class)).isTrue(); SecurityContext securityContext = capturedContext.asContext(SecurityContext.class); assertThat(securityContext.getAuthenticationId()).isEqualTo("test"); assertThat(securityContext.getAuthorization()).containsOnlyKeys("authLevel", "tokenId"); }