release 0.1 #30

Manually merged
noemi3 merged 150 commits from release/0.1 into master 2020-01-18 14:59:02 +00:00
3 changed files with 117 additions and 2 deletions
Showing only changes of commit eba0552540 - Show all commits

View File

@ -0,0 +1,20 @@
package wekan.wrapper.api;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import wekan.wrapper.entity.UserPrototype;
public interface LoginService {
/**
*
* @param username
* @param password
* @return User id and token
*/
@FormUrlEncoded
@POST("/users/login")
Call<UserPrototype> login(@Field("username") String username, @Field("password") String password);
}

View File

@ -1,8 +1,10 @@
package wekan.wrapper.api;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
import retrofit2.http.*;
import wekan.wrapper.entity.Action;
import wekan.wrapper.entity.Board;
import wekan.wrapper.entity.BoardPrototype;
import wekan.wrapper.entity.User;
import java.util.List;
@ -26,4 +28,46 @@ public interface UserService {
@GET("api/users/{user}")
Call<User> getUser(@Path("user") String userId);
/**
* Get current User
* @return the current user
*/
@GET("api/user")
Call<User> getCurrentUser();
/**
* Delete user
* @param userId
* @return
*/
@DELETE("api/users/{user}")
Call<User> delete(@Path("user") String userId);
/******************** Don't work ****************************************************/
@FormUrlEncoded
@POST("api/users")
@Headers("Content-Type: multipart/form-data")
Call<User> newUser(@Field("username") String username,
@Field("email") String email,
@Field("password") String password
);
@FormUrlEncoded
@Headers("Content-Type: multipart/form-data")
@POST("/api/boards/{board}/members/{user}/add")
Call<Board> addMemberToBoard(@Path("board") String boardId, @Path("user") String userId,
@Field("action") String action,
@Field("isAdmin") boolean b1,
@Field("isNoComments") boolean b2,
@Field("isCommentOnly") boolean b3);
@POST("api/boards/{board}/members/{user}/remove")
Call<Void> removeUserFromBoard(@Path("board") String boardId, @Path("user") String userId,
@Body Action action);
}

View File

@ -6,6 +6,8 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import wekan.wrapper.entity.Service;
@ -13,6 +15,7 @@ import wekan.wrapper.entity.User;
import wekan.wrapper.entity.UserEmail;
import wekan.wrapper.entity.UserProfile;
import javax.jws.soap.SOAPBinding;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
@ -110,6 +113,37 @@ public class UserServiceTest {
}
@Test
public void getCurrentUser(){
MockResponse mockResponse = new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_OK)
.setBody(user2);
mockWebServer.enqueue(mockResponse);
try {
User user = service.getCurrentUser().execute().body();
assert user != null;
UserProfile userProfile = user.getProfile();
assertNotNull(user);
assertEquals("jPdkf3a9bmfZWx3GR", user.getId());
assertEquals("umberto", user.getUsername());
assertEquals("password", user.getAuthenticationMethod());
assertTrue(user.isAdmin());
assertFalse(user.isLoginDisabled());
assertFalse(user.getEmails().isEmpty());
assertEquals(1, user.getEmails().size());
assertEquals("my@email.com", user.getEmails().get(0).getEmail());
assertNotNull(userProfile);
assertEquals("zo82BZYxFTNBpb7jX",
userProfile.getCardTemplatesSwimlaneId());
assertEquals("j6ZuPbwaN9nsCDxyS",
userProfile.getBoardTemplatesSwimlaneId());
} catch (IOException e) {
e.printStackTrace();
}
}
private static final String user1 = "{" +
"\"_id\":\"jPdkf3a9bmfZWx3GR\"," +
@ -150,4 +184,21 @@ public class UserServiceTest {
" }\n" +
"}\n" +
"}";
private final String user2 = "{" +
"\"_id\":\"jPdkf3a9bmfZWx3GR\"," +
"\"createdAt\":\"2019-10-14T18:14:38.249Z\"," +
"\"username\":\"umberto\"," +
"\"emails\":[{\"address\":\"my@email.com\"," +
"\"verified\":false}]," +
"\"modifiedAt\":\"2019-11-09T17:55:36.976Z\"," +
"\"profile\":{\"boardView\":\"board-view-swimlanes\"," +
"\"templatesBoardId\":\"eLvE8FnqvACfC9Rtb\"," +
"\"cardTemplatesSwimlaneId\":\"zo82BZYxFTNBpb7jX\"," +
"\"listTemplatesSwimlaneId\":\"Kja32A85P2HADWKFA\"," +
"\"boardTemplatesSwimlaneId\":\"j6ZuPbwaN9nsCDxyS\"," +
"\"listSortBy\":\"-modifiedAt\"}," +
"\"authenticationMethod\":\"password\"," +
"\"isAdmin\":true," +
"\"loginDisabled\":false}";
}