Skip to content

Commit

Permalink
Merge pull request #35 from dev-senior-com-br/bugfix/ecoapi-790
Browse files Browse the repository at this point in the history
#ECOAPI-790 - Atualização do endpoint getUser do User
  • Loading branch information
Lemoel authored Aug 14, 2020
2 parents 95d0c4b + 4e2b3ba commit 1799714
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@
public class GetUserInput {

/**
* "Nome do usuário no formato nome@dominio_tenant"
* Nome do usuário no formato nome@dominio_tenant
*/
@NonNull
String username;

/**
* Email do usuário
*/
@NonNull
String email;

}
51 changes: 20 additions & 31 deletions src/main/java/br/com/senior/core/user/pojos/GetUserOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,83 +16,72 @@ public class GetUserOutput {
/**
* Identificador do usuário
*/
String id;

String id;
/**
* Nome do usuário
*/
String username;

String username;
/**
* Nome completo do usuário
*/
String fullName;

String fullName;
/**
* Descrição do usuário
*/
String description;

String description;
/**
* Endereço de e-mail do usuário
*/
String email;

String email;
/**
* localidade do usuário
*/
String locale;

String locale;
/**
* Domínio do tenant no login do usuário
*/
String tenantDomain;

String tenantDomain;
/**
* Nome do tenant do usuário
*/
String tenantName;

String tenantName;
/**
* Localidade do tenant do usuário
*/
String tenantLocale;

String tenantLocale;
/**
* Indica se o usuário está bloqueado
*/
Boolean blocked;

Boolean blocked;
/**
* Tipo de autenticação utilizada pelo tenant deste usuário
*/
AuthType authenticationType;

AuthType authenticationType;
/**
* Dados do usuário integrado pela G5, mas futuramente poderá ser utilizado para outras integrações se necessário
*/
Integration integration;
/**
* Indica se o usuário precisa trocar de senha no próximo logon
*/
Boolean changePassword;

Boolean changePassword;
/**
* Foto do usuário em Base64
*/
String photo;

String photo;
/**
* Lista com as propriedades que este usuário possui (opcional)
*/
List properties;

java.util.List<Property> properties;
/**
* Indica se o usuário é um admin de tenant
*/
Boolean admin;

Boolean admin;
/**
* Indica se o usuário pode alterar a sua senha.
* É possível alterar a senha quando o tipo de autenticação do tenant é G7 ou quando é G5 e o tenant está configurado para permitir alterar a senha pela G7.
*/
Boolean allowedToChangePassword;
Boolean allowedToChangePassword;

/**
* @param id - Identificador do usuário
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/br/com/senior/core/user/pojos/Integration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package br.com.senior.core.user.pojos;

import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;

@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class Integration {
/**
* Nome do usuário recebido via integração, caso não tenha um usuário informado na coluna 'integration_username' será retornado o usuário padrão
*/
String integrationName;
/**
* Código do usuário, aplicado para os usuários integrados através da G5
*/
String integrationCode;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package br.com.senior.core.authentication;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import br.com.senior.core.BaseIT;
import br.com.senior.core.authentication.pojos.LoginMFAInput;
import br.com.senior.core.authentication.pojos.LoginOutput;
Expand All @@ -14,10 +10,14 @@
import br.com.senior.core.authentication.pojos.RefreshTokenInput;
import br.com.senior.core.authentication.pojos.RefreshTokenOutput;
import br.com.senior.core.authentication.pojos.Scope;
import br.com.senior.core.base.ServiceException;
import br.com.senior.core.user.UserClient;
import br.com.senior.core.user.pojos.GetUserInput;
import br.com.senior.core.user.pojos.GetUserOutput;
import br.com.senior.core.base.ServiceException;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

/**
* Exemplos de código do {@link br.com.senior.core.authentication.AuthenticationClient AuthenticationClient}
Expand All @@ -32,7 +32,7 @@ public void testValidLogin() throws ServiceException {
}

@Test
public void testInvalidLogin() throws ServiceException {
public void testInvalidLogin() {
Assert.assertThrows(ServiceException.class, () -> login(System.getenv("SENIOR_USERNAME"), System.getenv("PASSWORD_INVALID")));
}

Expand Down Expand Up @@ -81,11 +81,10 @@ public void testRefreshTokenWithScope() throws ServiceException {

LoginOutput loginOutput = login();
String username = loginOutput.getJsonToken().getUsername();
String email = loginOutput.getJsonToken().getUsername();
String accessToken = loginOutput.getJsonToken().getAccess_token();
String refreshToken = loginOutput.getJsonToken().getRefresh_token();

GetUserInput getUserInput = new GetUserInput(username, email);
GetUserInput getUserInput = new GetUserInput(username);
GetUserOutput getUserOutput = new UserClient(accessToken).getUser(getUserInput);

RefreshTokenInput refreshTokenInput = new RefreshTokenInput(refreshToken, Scope.DESKTOP.toString());
Expand All @@ -99,11 +98,10 @@ public void testRefreshTokenWithScope() throws ServiceException {
public void testRefreshTokenScopeLess() throws ServiceException {
LoginOutput loginOutput = login();
String username = loginOutput.getJsonToken().getUsername();
String email = loginOutput.getJsonToken().getUsername();
String accessToken = loginOutput.getJsonToken().getAccess_token();
String refreshToken = loginOutput.getJsonToken().getRefresh_token();

GetUserInput getUserInput = new GetUserInput(username, email);
GetUserInput getUserInput = new GetUserInput(username);
GetUserOutput getUserOutput = new UserClient(accessToken).getUser(getUserInput);

RefreshTokenInput refreshTokenInput = new RefreshTokenInput(refreshToken);
Expand Down
45 changes: 20 additions & 25 deletions src/test/java/br/com/senior/core/user/UserIT.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
package br.com.senior.core.user;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;

import java.util.Arrays;
import java.util.List;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import br.com.senior.core.BaseIT;
import br.com.senior.core.base.ServiceException;
import br.com.senior.core.user.pojos.CreateGroupInput;
import br.com.senior.core.user.pojos.CreateGroupOutput;
import br.com.senior.core.user.pojos.CreateUserInput;
Expand All @@ -29,7 +20,15 @@
import br.com.senior.core.user.pojos.UpdateGroupUsersOutput;
import br.com.senior.core.user.pojos.UpdateUserInput;
import br.com.senior.core.user.pojos.UpdateUserOutput;
import br.com.senior.core.base.ServiceException;

import java.util.List;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;

/**
* Exemplos de código do {@link br.com.senior.core.user.UserClient UserClient}
Expand All @@ -38,22 +37,26 @@ public class UserIT extends BaseIT {

private static final String USER_NAME = "teste";
private static final String USER_EMAIL = "teste@test.com.br";
private static final String GROUP_NAME = "GrupoParaTestes";
private static String USER_ID;

private static String GROUP_ID;
private static final String GROUP_NAME = "GrupoParaTestes";

private static String usernameExpected;
private static String token;
private static UserClient client;

@BeforeClass
public static void beforeClass() throws ServiceException {
usernameExpected = Arrays.stream(System.getenv("SENIOR_USERNAME").split("@")).findFirst().orElse(null);
token = login().getJsonToken().getAccess_token();
client = new UserClient(token);
}

private static void deleteGroup() throws ServiceException {
client.deleteGroup(GROUP_ID);
}

private static void deleteUser() throws ServiceException {
client.deleteUser(USER_ID);
}

@Test
public void testCreateAndGetGroup() throws ServiceException {
try {
Expand Down Expand Up @@ -204,14 +207,6 @@ public void testDeleteGroup() throws Exception {
}
}

private static void deleteGroup() throws ServiceException {
client.deleteGroup(GROUP_ID);
}

private static void deleteUser() throws ServiceException {
client.deleteUser(USER_ID);
}

private GetGroupOutput getGroup() throws ServiceException {
GetGroupInput input = new GetGroupInput(GROUP_ID);
return client.getGroup(input);
Expand Down Expand Up @@ -248,7 +243,7 @@ private ListGroupUsersOutput listGroupUsers() throws ServiceException {
}

private GetUserOutput getUser() throws ServiceException {
GetUserInput input = new GetUserInput(USER_NAME, USER_EMAIL);
GetUserInput input = new GetUserInput(USER_NAME);
return client.getUser(input);
}

Expand Down

0 comments on commit 1799714

Please sign in to comment.