This commit is contained in:
parent
8e5c93fb04
commit
eaded60e46
21
wrapper/src/main/java/wekan/wrapper/entity/Password.java
Normal file
21
wrapper/src/main/java/wekan/wrapper/entity/Password.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package wekan.wrapper.entity;
|
||||||
|
|
||||||
|
public class Password {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Password{" +
|
||||||
|
"bcrypt='" + bcrypt + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBcrypt() {
|
||||||
|
return bcrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBcrypt(String bcrypt) {
|
||||||
|
this.bcrypt = bcrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String bcrypt;
|
||||||
|
}
|
30
wrapper/src/main/java/wekan/wrapper/entity/Resume.java
Normal file
30
wrapper/src/main/java/wekan/wrapper/entity/Resume.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package wekan.wrapper.entity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps track of access through the LoginToken list
|
||||||
|
* LoginToken contains the hash code of the access token
|
||||||
|
* and the date of that access
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Resume {
|
||||||
|
|
||||||
|
public List<LoginToken> getLoginTokens() {
|
||||||
|
return loginTokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoginTokens(List<LoginToken> loginTokens) {
|
||||||
|
this.loginTokens = loginTokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Resume{" +
|
||||||
|
"loginTokens=" + loginTokens +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<LoginToken> loginTokens;
|
||||||
|
}
|
41
wrapper/src/main/java/wekan/wrapper/entity/Service.java
Normal file
41
wrapper/src/main/java/wekan/wrapper/entity/Service.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package wekan.wrapper.entity;
|
||||||
|
|
||||||
|
public class Service {
|
||||||
|
|
||||||
|
public Email getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(Email email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resume getResume() {
|
||||||
|
return resume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResume(Resume resume) {
|
||||||
|
this.resume = resume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Password getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(Password password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Service{" +
|
||||||
|
"email=" + email +
|
||||||
|
", resume=" + resume +
|
||||||
|
", password=" + password +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
private Email email;
|
||||||
|
private Resume resume;
|
||||||
|
private Password password;
|
||||||
|
}
|
@ -95,6 +95,14 @@ public class User {
|
|||||||
this.authenticationMethod = authenticationMethod;
|
this.authenticationMethod = authenticationMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Service getServices() {
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServices(Service services) {
|
||||||
|
this.services = services;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "User{" +
|
return "User{" +
|
||||||
@ -109,9 +117,11 @@ public class User {
|
|||||||
", createdThroughApi=" + createdThroughApi +
|
", createdThroughApi=" + createdThroughApi +
|
||||||
", loginDisabled=" + loginDisabled +
|
", loginDisabled=" + loginDisabled +
|
||||||
", authenticationMethod='" + authenticationMethod + '\'' +
|
", authenticationMethod='" + authenticationMethod + '\'' +
|
||||||
|
", services='" + services + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SerializedName("_id")
|
@SerializedName("_id")
|
||||||
private String id;
|
private String id;
|
||||||
private String username;
|
private String username;
|
||||||
@ -119,8 +129,7 @@ public class User {
|
|||||||
private Date createdAt;
|
private Date createdAt;
|
||||||
private Date modifiedAt;
|
private Date modifiedAt;
|
||||||
private UserProfile profile;
|
private UserProfile profile;
|
||||||
//Class Service doesn't implemented in API
|
private Service services;
|
||||||
//private Service service;
|
|
||||||
private String heartbeat;
|
private String heartbeat;
|
||||||
private boolean isAdmin;
|
private boolean isAdmin;
|
||||||
private boolean createdThroughApi;
|
private boolean createdThroughApi;
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
package wekan.wrapper.entity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class VerificationToken {
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToken(String token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getWhen() {
|
||||||
|
return when;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWhen(Date when) {
|
||||||
|
this.when = when;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "VerificationToken{" +
|
||||||
|
"token='" + token + '\'' +
|
||||||
|
", address='" + address + '\'' +
|
||||||
|
", when=" + when +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
private String token;
|
||||||
|
private String address;
|
||||||
|
private Date when;
|
||||||
|
}
|
@ -8,6 +8,7 @@ import org.junit.Test;
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
import wekan.wrapper.entity.Service;
|
||||||
import wekan.wrapper.entity.User;
|
import wekan.wrapper.entity.User;
|
||||||
import wekan.wrapper.entity.UserEmail;
|
import wekan.wrapper.entity.UserEmail;
|
||||||
import wekan.wrapper.entity.UserProfile;
|
import wekan.wrapper.entity.UserProfile;
|
||||||
@ -82,17 +83,25 @@ public class UserServiceTest {
|
|||||||
assert user != null;
|
assert user != null;
|
||||||
List<UserEmail> userEmail = user.getEmails();
|
List<UserEmail> userEmail = user.getEmails();
|
||||||
UserProfile userProfile = user.getProfile();
|
UserProfile userProfile = user.getProfile();
|
||||||
|
Service ser = user.getServices();
|
||||||
assertEquals("jPdkf3a9bmfZWx3GR", user.getId());
|
assertEquals("jPdkf3a9bmfZWx3GR", user.getId());
|
||||||
assertEquals("umberto", user.getUsername());
|
assertEquals("umberto", user.getUsername());
|
||||||
assertEquals("password", user.getAuthenticationMethod());
|
assertEquals("password", user.getAuthenticationMethod());
|
||||||
assertTrue(user.isAdmin());
|
assertTrue(user.isAdmin());
|
||||||
assertEquals("2019-10-14T18:14:38.249Z", user.getCreatedAt());
|
assertEquals("Mon Oct 14 20:14:38 CEST 2019", user.getCreatedAt().toString());
|
||||||
assertFalse(userEmail.isEmpty());
|
assertFalse(userEmail.isEmpty());
|
||||||
assertEquals("umbertof993@gmail.com", userEmail.get(0).getEmail());
|
assertEquals("my@email.com", userEmail.get(0).getEmail());
|
||||||
assertFalse(userEmail.get(0).isVerified());
|
assertFalse(userEmail.get(0).isVerified());
|
||||||
assertEquals("board-view-swimlanes", userProfile.getBoardView());
|
assertEquals("BOARD_VIEW_SWIMLANES", userProfile.getBoardView().toString());
|
||||||
assertEquals("zo82BZYxFTNBpb7jX", userProfile.getCardTemplatesSwimlaneId());
|
assertEquals("zo82BZYxFTNBpb7jX", userProfile.getCardTemplatesSwimlaneId());
|
||||||
assertEquals("-modifiedAt", userProfile.getListSortBy());
|
assertEquals("_MODIFIEDAT", userProfile.getListSortBy().toString());
|
||||||
|
assertEquals(1, ser.getEmail().getVerificationTokens().size());
|
||||||
|
assertEquals("my@email.com",
|
||||||
|
ser.getEmail().getVerificationTokens().get(0).getAddress());
|
||||||
|
assertEquals("$2a$10$CRZrpT4x.VpG2FdJxR3rN.9m0NbQb0OPsSPBDAZukggxrskMtWA8.",
|
||||||
|
ser.getPassword().getBcrypt());
|
||||||
|
assertEquals(2, ser.getResume().getLoginTokens().size());
|
||||||
|
assertEquals("CY/PWeDa3fAkl+k94+GWzCtpB5nPcVxLzzzjXs4kI3A=", ser.getResume().getLoginTokens().get(0).getHashedToken());
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -105,7 +114,7 @@ public class UserServiceTest {
|
|||||||
private static final String user1 = "{" +
|
private static final String user1 = "{" +
|
||||||
"\"_id\":\"jPdkf3a9bmfZWx3GR\"," +
|
"\"_id\":\"jPdkf3a9bmfZWx3GR\"," +
|
||||||
"\"username\":\"umberto\"," +
|
"\"username\":\"umberto\"," +
|
||||||
"\"emails\":[{\"address\":\"umbertof993@gmail.com\",\"verified\":false}]," +
|
"\"emails\":[{\"address\":\"my@email.com\",\"verified\":false}]," +
|
||||||
"\"authenticationMethod\":\"password\"," +
|
"\"authenticationMethod\":\"password\"," +
|
||||||
"\"isAdmin\":\"true\"," +
|
"\"isAdmin\":\"true\"," +
|
||||||
"\"loginDisabled\":\"true\"," +
|
"\"loginDisabled\":\"true\"," +
|
||||||
@ -114,5 +123,31 @@ public class UserServiceTest {
|
|||||||
"\"boardTemplatesSwimlaneId\":\"j6ZuPbwaN9nsCDxyS\",\"listSortBy\":\"-modifiedAt\"}," +
|
"\"boardTemplatesSwimlaneId\":\"j6ZuPbwaN9nsCDxyS\",\"listSortBy\":\"-modifiedAt\"}," +
|
||||||
"\"createdAt\":\"2019-10-14T18:14:38.249Z\","+
|
"\"createdAt\":\"2019-10-14T18:14:38.249Z\","+
|
||||||
"\"modifiedAt\":\"2019-11-09T17:55:36.976Z\"," +
|
"\"modifiedAt\":\"2019-11-09T17:55:36.976Z\"," +
|
||||||
|
"\"services\":{\n" +
|
||||||
|
" \"password\":{\n" +
|
||||||
|
" \"bcrypt\":\"$2a$10$CRZrpT4x.VpG2FdJxR3rN.9m0NbQb0OPsSPBDAZukggxrskMtWA8.\"\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"email\":{\n" +
|
||||||
|
" \"verificationTokens\":[\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"token\":\"8rzwpq_So2PVYHVSfrcc5f5QZnuV2wEtu7QRQGwOJx8\",\n" +
|
||||||
|
" \"address\":\"my@email.com\",\n" +
|
||||||
|
" \"when\":\"2017-09-13T06:45:53.157Z\"\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ]\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"resume\":{\n" +
|
||||||
|
" \"loginTokens\":[\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"when\":\"2017-09-13T06:45:53.265Z\",\n" +
|
||||||
|
" \"hashedToken\":\"CY/PWeDa3fAkl+k94+GWzCtpB5nPcVxLzzzjXs4kI3A=\"\n" +
|
||||||
|
" },\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"when\":\"2017-09-16T06:06:19.741Z\",\n" +
|
||||||
|
" \"hashedToken\":\"74MQNXfsgjkItx/gpgPb29Y0MSNAvBrsnSGQmr4YGvQ=\"\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ]\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}\n" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user