use of org.jboss.errai.security.shared.api.identity.User in project kie-wb-common by kiegroup.
the class SafeSessionInfoProvider method createSessionInfo.
private SessionInfo createSessionInfo() {
String id = getId();
User identity = getUserFromIdentityProvider();
return new SessionInfoImpl(id, identity);
}
use of org.jboss.errai.security.shared.api.identity.User in project kie-wb-common by kiegroup.
the class ProjectImportServiceImplRepositoryNamesTest method setup.
@Before
public void setup() {
service = spy(new ProjectImportServiceImpl(ioService, metadataService, repositoryFactory, moduleService, validators, pathUtil, projectService, projectScreenService, newProjectEvent, repoService, spaceConfigStorageRegistry));
when(spaceConfigStorageRegistry.get(anyString())).thenReturn(spaceConfigStorage);
when(spaceConfigStorageRegistry.getBatch(anyString())).thenReturn(new SpaceConfigStorageRegistryImpl.SpaceStorageBatchImpl(spaceConfigStorage));
when(spaceConfigStorageRegistry.exist(anyString())).thenReturn(true);
when(validators.getValidators()).thenReturn(new ArrayList<>());
when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {
{
add(new OrganizationalUnitImpl("ou1Name", "ou1GroupId"));
}
});
when(moduleService.resolveModule(any(Path.class))).thenAnswer((Answer<KieModule>) invocationOnMock -> {
final Path path = (Path) invocationOnMock.getArguments()[0];
final KieModule module = new KieModule(path, path, path, path, path, path, mock(POM.class));
return module;
});
when(sessionInfo.getId()).thenReturn("sessionId");
when(sessionInfo.getIdentity()).thenReturn(user);
when(user.getIdentifier()).thenReturn("user");
exProject1 = mock(ImportProject.class);
importProjects = Collections.singletonList(exProject1);
final OrganizationalUnit ou = mock(OrganizationalUnit.class);
doReturn("ou").when(ou).getName();
final GitRepository repository1 = mock(GitRepository.class);
final Path repositoryRoot = mock(Path.class);
final Path module1Root = mock(Path.class);
when(organizationalUnit.getName()).thenReturn("ou");
when(organizationalUnit.getSpace()).thenReturn(space);
when(space.getName()).thenReturn("ou");
when(exProject1.getName()).thenReturn("module1");
when(exProject1.getRoot()).thenReturn(module1Root);
when(repository1.getBranch("dev_branch")).thenReturn(Optional.of(new Branch("dev_branch", repositoryRoot)));
final Optional<Branch> main = Optional.of(new Branch("main", PathFactory.newPath("testFile", "file:///")));
when(repository1.getDefaultBranch()).thenReturn(main);
when(repositoryRoot.toURI()).thenReturn("default:///");
when(module1Root.toURI()).thenReturn("default:///module1");
when(ouService.getOrganizationalUnit(eq("ou"))).thenReturn(ou);
doReturn("module1").when(repository1).getAlias();
final WorkspaceProject project = spy(new WorkspaceProject());
doReturn(repository1.getAlias()).when(project).getName();
doReturn(mock(Module.class)).when(project).getMainModule();
doReturn(mock(OrganizationalUnit.class)).when(project).getOrganizationalUnit();
doReturn(project).when(projectService).resolveProject(repository1);
doReturn(project).when(projectService).resolveProject(any(Path.class));
final ProjectScreenModel model = new ProjectScreenModel();
model.setPOM(new POM());
doReturn(model).when(projectScreenService).load(any());
}
use of org.jboss.errai.security.shared.api.identity.User in project drools-wb by kiegroup.
the class DecisionTableXLSServiceImplTest method assertCommentedOption.
private void assertCommentedOption() {
this.service = getServiceWithValidationOverride((tempFile) -> {
// Do nothing; tests do not use a *real* XLS file
});
final CommentedOption commentedOption = commentedOptionArgumentCaptor.getValue();
assertNotNull(commentedOption);
assertEquals("user", commentedOption.getName());
assertEquals("123", commentedOption.getSessionId());
}
use of org.jboss.errai.security.shared.api.identity.User in project kie-wb-common by kiegroup.
the class SafeIdentityProvider method getRoles.
@Override
public List<String> getRoles() {
List<String> roles = new ArrayList<>();
if (identityInstance.isUnsatisfied()) {
// TODO: retrieve roles via info in servlet request and JAAS?
return roles;
}
// default
User identity = identityInstance.get();
final Set<Role> ufRoles = identity.getRoles();
for (Role role : ufRoles) {
roles.add(role.getName());
}
final Set<Group> ufGroups = identity.getGroups();
for (Group group : ufGroups) {
roles.add(group.getName());
}
return roles;
}
use of org.jboss.errai.security.shared.api.identity.User in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method getAllUsersSuccessTest.
@Test
public void getAllUsersSuccessTest() {
final User user = mock(User.class);
doReturn("admin").when(user).getIdentifier();
final List<User> users = Collections.singletonList(user);
final AbstractEntityManager.SearchResponse<User> searchResponse = mock(AbstractEntityManager.SearchResponse.class);
doReturn(users).when(searchResponse).getResults();
doReturn(searchResponse).when(userManagerService).search(any());
final List<String> allUsers = libraryService.getAllUsers();
assertEquals(1, allUsers.size());
assertEquals("admin", allUsers.get(0));
}
Aggregations