package info.elexis.server.core.rest.test.swagger;

import static info.elexis.server.core.rest.test.AllTests.REST_URL;
import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.net.HttpURLConnection;

import org.junit.Test;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import info.elexis.server.core.rest.test.AllTests;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class SwaggerTest {

	private OkHttpClient client = AllTests.getDefaultOkHttpClient();
	private Response response;

	Gson gson = new Gson();
	
	@Test
	public void testGetSwaggerConfiguration() throws IOException {
		Request request = new Request.Builder().url(REST_URL + "/swagger.json").get().build();
		response = client.newCall(request).execute();
		assertEquals(HttpURLConnection.HTTP_OK, response.code());
		
		String swaggerJson = response.body().string();
		JsonElement jelem = gson.fromJson(swaggerJson, JsonElement.class);
		JsonObject swagger = jelem.getAsJsonObject();
		
		JsonObject securityDefinitions = swagger.getAsJsonObject("securityDefinitions");
		JsonObject esoAuth = securityDefinitions.get("esoauth").getAsJsonObject();
		assertEquals("oauth2", esoAuth.get("type").getAsString());
	}

}

@@ -1016,16 +1016,18 @@
 class);%0A
+//
 %09%09JsonOb
@@ -1069,16 +1069,18 @@
 t();%0A%09%09%0A
+//
 %09%09JsonOb
@@ -1154,16 +1154,18 @@
 ions%22);%0A
+//
 %09%09JsonOb
@@ -1229,24 +1229,26 @@
 onObject();%0A
+//
 %09%09assertEqua

Remove HTTPS support, fix swagger test