use of org.cloudfoundry.identity.uaa.approval.JdbcApprovalStore in project uaa by cloudfoundry.
the class JdbcApprovalStoreTests method setUp.
@BeforeEach
void setUp() {
generator = new RandomValueStringGenerator();
defaultZoneId = "defaultZoneId-" + generator.generate();
otherZoneId = "otherZoneId-" + generator.generate();
Stream.of("u1", "u2", "u3").forEach(userId -> testAccounts.addUser(jdbcTemplate, userId, defaultZoneId));
jdbcApprovalStore = new JdbcApprovalStore(jdbcTemplate);
eventPublisher = TestApplicationEventPublisher.forEventClass(ApprovalModifiedEvent.class);
jdbcApprovalStore.setApplicationEventPublisher(eventPublisher);
addApproval(jdbcApprovalStore, "u1", "c1", "uaa.user", 6000, APPROVED, defaultZoneId);
addApproval(jdbcApprovalStore, "u1", "c2", "uaa.admin", 12000, DENIED, defaultZoneId);
addApproval(jdbcApprovalStore, "u2", "c1", "openid", 6000, APPROVED, defaultZoneId);
}
use of org.cloudfoundry.identity.uaa.approval.JdbcApprovalStore in project uaa by cloudfoundry.
the class UserManagedAuthzApprovalHandlerTests method setUp.
@BeforeEach
void setUp(@Autowired JdbcTemplate jdbcTemplate) {
RandomValueStringGenerator generator = new RandomValueStringGenerator();
currentIdentityZoneId = "currentIdentityZoneId-" + generator.generate();
approvalStore = new JdbcApprovalStore(jdbcTemplate);
QueryableResourceManager<ClientDetails> mockClientDetailsService = mock(QueryableResourceManager.class);
mockBaseClientDetails = mock(BaseClientDetails.class);
when(mockClientDetailsService.retrieve("foo", currentIdentityZoneId)).thenReturn(mockBaseClientDetails);
when(mockBaseClientDetails.getScope()).thenReturn(new HashSet<>(Arrays.asList("cloud_controller.read", "cloud_controller.write", "openid", "space.*.developer")));
when(mockBaseClientDetails.getAutoApproveScopes()).thenReturn(Collections.emptySet());
IdentityZoneManager mockIdentityZoneManager = mock(IdentityZoneManager.class);
when(mockIdentityZoneManager.getCurrentIdentityZoneId()).thenReturn(currentIdentityZoneId);
handler = new UserManagedAuthzApprovalHandler(approvalStore, mockClientDetailsService, mockIdentityZoneManager);
userId = "userId-" + generator.generate();
mockAuthentication = mock(AuthenticationWithGetId.class);
when(mockAuthentication.isAuthenticated()).thenReturn(true);
when(mockAuthentication.getId()).thenReturn(userId);
nextWeek = new Date(LocalDateTime.now().plus(Duration.ofDays(7)).atZone(ZoneId.systemDefault()).toEpochSecond() * 1000);
}
use of org.cloudfoundry.identity.uaa.approval.JdbcApprovalStore in project uaa by cloudfoundry.
the class ApprovalsAdminEndpointsTests method initApprovalsAdminEndpointsTests.
@BeforeEach
void initApprovalsAdminEndpointsTests() {
UaaTestAccounts testAccounts = UaaTestAccounts.standard(null);
String id = UUID.randomUUID().toString();
String userId = testAccounts.addUser(jdbcTemplate, id, IdentityZoneHolder.get().getId());
IdentityZoneManager mockIdentityZoneManager = mock(IdentityZoneManager.class);
when(mockIdentityZoneManager.getCurrentIdentityZoneId()).thenReturn(IdentityZone.getUaaZoneId());
IdentityZone mockIdentityZone = mock(IdentityZone.class);
when(mockIdentityZoneManager.getCurrentIdentityZone()).thenReturn(mockIdentityZone);
when(mockIdentityZone.getConfig()).thenReturn(IdentityZone.getUaa().getConfig());
UaaUserDatabase userDao = new JdbcUaaUserDatabase(jdbcTemplate, new TimeServiceImpl(), false, mockIdentityZoneManager);
marissa = userDao.retrieveUserById(userId);
assertNotNull(marissa);
dao = new JdbcApprovalStore(jdbcTemplate);
mockSecurityContextAccessor = mock(SecurityContextAccessor.class);
when(mockSecurityContextAccessor.getUserName()).thenReturn(marissa.getUsername());
when(mockSecurityContextAccessor.getUserId()).thenReturn(marissa.getId());
when(mockSecurityContextAccessor.isUser()).thenReturn(true);
MultitenantJdbcClientDetailsService clientDetailsService = new MultitenantJdbcClientDetailsService(jdbcTemplate, mockIdentityZoneManager, passwordEncoder);
BaseClientDetails details = new BaseClientDetails("c1", "scim,clients", "read,write", "authorization_code, password, implicit, client_credentials", "update");
details.setAutoApproveScopes(Collections.singletonList("true"));
clientDetailsService.addClientDetails(details);
endpoints = new ApprovalsAdminEndpoints(mockSecurityContextAccessor, dao, userDao, clientDetailsService);
}
Aggregations