diff --git a/wrapper/src/main/java/wekan/wrapper/entity/Password.java b/wrapper/src/main/java/wekan/wrapper/entity/Password.java new file mode 100644 index 0000000..cf6048f --- /dev/null +++ b/wrapper/src/main/java/wekan/wrapper/entity/Password.java @@ -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; +} diff --git a/wrapper/src/main/java/wekan/wrapper/entity/Resume.java b/wrapper/src/main/java/wekan/wrapper/entity/Resume.java new file mode 100644 index 0000000..d79a9d0 --- /dev/null +++ b/wrapper/src/main/java/wekan/wrapper/entity/Resume.java @@ -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 getLoginTokens() { + return loginTokens; + } + + public void setLoginTokens(List loginTokens) { + this.loginTokens = loginTokens; + } + + @Override + public String toString() { + return "Resume{" + + "loginTokens=" + loginTokens + + '}'; + } + + private List loginTokens; +} diff --git a/wrapper/src/main/java/wekan/wrapper/entity/Service.java b/wrapper/src/main/java/wekan/wrapper/entity/Service.java new file mode 100644 index 0000000..392b532 --- /dev/null +++ b/wrapper/src/main/java/wekan/wrapper/entity/Service.java @@ -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; +} diff --git a/wrapper/src/main/java/wekan/wrapper/entity/User.java b/wrapper/src/main/java/wekan/wrapper/entity/User.java index 2560edd..8146d78 100644 --- a/wrapper/src/main/java/wekan/wrapper/entity/User.java +++ b/wrapper/src/main/java/wekan/wrapper/entity/User.java @@ -95,6 +95,14 @@ public class User { this.authenticationMethod = authenticationMethod; } + public Service getServices() { + return services; + } + + public void setServices(Service services) { + this.services = services; + } + @Override public String toString() { return "User{" + @@ -109,9 +117,11 @@ public class User { ", createdThroughApi=" + createdThroughApi + ", loginDisabled=" + loginDisabled + ", authenticationMethod='" + authenticationMethod + '\'' + + ", services='" + services + '\'' + '}'; } + @SerializedName("_id") private String id; private String username; @@ -119,8 +129,7 @@ public class User { private Date createdAt; private Date modifiedAt; private UserProfile profile; - //Class Service doesn't implemented in API - //private Service service; + private Service services; private String heartbeat; private boolean isAdmin; private boolean createdThroughApi; diff --git a/wrapper/src/main/java/wekan/wrapper/entity/VerificationToken.java b/wrapper/src/main/java/wekan/wrapper/entity/VerificationToken.java new file mode 100644 index 0000000..1797ee7 --- /dev/null +++ b/wrapper/src/main/java/wekan/wrapper/entity/VerificationToken.java @@ -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; +} diff --git a/wrapper/src/test/java/wekan/wrapper/api/UserServiceTest.java b/wrapper/src/test/java/wekan/wrapper/api/UserServiceTest.java index c93a60d..defcbc3 100644 --- a/wrapper/src/test/java/wekan/wrapper/api/UserServiceTest.java +++ b/wrapper/src/test/java/wekan/wrapper/api/UserServiceTest.java @@ -8,6 +8,7 @@ import org.junit.Test; import static org.junit.Assert.*; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; +import wekan.wrapper.entity.Service; import wekan.wrapper.entity.User; import wekan.wrapper.entity.UserEmail; import wekan.wrapper.entity.UserProfile; @@ -82,17 +83,25 @@ public class UserServiceTest { assert user != null; List userEmail = user.getEmails(); UserProfile userProfile = user.getProfile(); + Service ser = user.getServices(); assertEquals("jPdkf3a9bmfZWx3GR", user.getId()); assertEquals("umberto", user.getUsername()); assertEquals("password", user.getAuthenticationMethod()); 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()); - assertEquals("umbertof993@gmail.com", userEmail.get(0).getEmail()); + assertEquals("my@email.com", userEmail.get(0).getEmail()); assertFalse(userEmail.get(0).isVerified()); - assertEquals("board-view-swimlanes", userProfile.getBoardView()); + assertEquals("BOARD_VIEW_SWIMLANES", userProfile.getBoardView().toString()); 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) { e.printStackTrace(); @@ -105,7 +114,7 @@ public class UserServiceTest { private static final String user1 = "{" + "\"_id\":\"jPdkf3a9bmfZWx3GR\"," + "\"username\":\"umberto\"," + - "\"emails\":[{\"address\":\"umbertof993@gmail.com\",\"verified\":false}]," + + "\"emails\":[{\"address\":\"my@email.com\",\"verified\":false}]," + "\"authenticationMethod\":\"password\"," + "\"isAdmin\":\"true\"," + "\"loginDisabled\":\"true\"," + @@ -114,5 +123,31 @@ public class UserServiceTest { "\"boardTemplatesSwimlaneId\":\"j6ZuPbwaN9nsCDxyS\",\"listSortBy\":\"-modifiedAt\"}," + "\"createdAt\":\"2019-10-14T18:14:38.249Z\","+ "\"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" + "}"; }