|
|
@@ -2,7 +2,13 @@ package com.malk.service.eiam.impl;
|
|
|
|
|
|
import com.malk.server.common.McException;
|
|
|
import com.malk.server.eiam.EiamApiResponse;
|
|
|
+import com.malk.server.eiam.EiamConf;
|
|
|
+import com.sun.net.httpserver.HttpServer;
|
|
|
import org.junit.Test;
|
|
|
+import org.springframework.test.util.ReflectionTestUtils;
|
|
|
+
|
|
|
+import java.net.InetSocketAddress;
|
|
|
+import java.util.Collections;
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
import static org.junit.Assert.assertNull;
|
|
|
@@ -47,4 +53,27 @@ public class EiamClient_UserImplTest {
|
|
|
|
|
|
assertNull(response.getCode());
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void patchUser_emptyResponse_returnsSuccessPayload() throws Exception {
|
|
|
+ HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
|
|
|
+ server.createContext("/v2/instance/application/users/user_test", exchange -> {
|
|
|
+ exchange.sendResponseHeaders(204, -1);
|
|
|
+ exchange.close();
|
|
|
+ });
|
|
|
+ server.start();
|
|
|
+ try {
|
|
|
+ EiamConf conf = new EiamConf();
|
|
|
+ conf.setBaseUrl("http://127.0.0.1:" + server.getAddress().getPort());
|
|
|
+ EiamClient_UserImpl client = new EiamClient_UserImpl();
|
|
|
+ ReflectionTestUtils.setField(client, "eiamConf", conf);
|
|
|
+
|
|
|
+ EiamApiResponse response = client.patchUser("token", "instance", "application",
|
|
|
+ "user_test", Collections.singletonMap("username", "17612168216"));
|
|
|
+
|
|
|
+ assertNull(response.getCode());
|
|
|
+ } finally {
|
|
|
+ server.stop(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|