Commit 49349d83 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

documentation for configuration option API calls

parent 0a00c60e
= Rest API Documentation - Configuration
Piotr Gawron
v{project-version} {build-time}
:toc: left
:sectnums:
== Details
Return full configuration details.
=== CURL sample
include::{snippets}/configuration/details/curl-request.adoc[]
=== Response Fields
include::{snippets}/configuration/details/response-fields.adoc[]
=== Sample Response
include::{snippets}/configuration/details/response-body.adoc[]
== List configuration options
List configuration options.
=== CURL sample
include::{snippets}/configuration/list_options/curl-request.adoc[]
=== Response Fields
include::{snippets}/configuration/list_options/response-fields.adoc[]
=== Sample Response
include::{snippets}/configuration/list_options/response-body.adoc[]
== Modify configuration option
Modify configuration option.
=== CURL sample
include::{snippets}/configuration/modify_option/curl-request.adoc[]
=== Path Parameters
include::{snippets}/configuration/modify_option/path-parameters.adoc[]
=== Request Fields
include::{snippets}/configuration/modify_option/request-fields.adoc[]
=== Response Fields
include::{snippets}/configuration/modify_option/response-fields.adoc[]
=== Sample Response
include::{snippets}/configuration/modify_option/response-body.adoc[]
== DAPI configuration details
Provide information about DAPI connection.
=== CURL sample
include::{snippets}/configuration/dapi/details/curl-request.adoc[]
=== Response Fields
include::{snippets}/configuration/dapi/details/response-fields.adoc[]
=== Sample Response
include::{snippets}/configuration/dapi/details/response-body.adoc[]
== Register new DAPI user
Creates new DAPI user in the https://dapi.lcsb.uni.lu/ system.
=== CURL sample
include::{snippets}/configuration/dapi/registerUser/curl-request.adoc[]
=== Request Parameters
include::{snippets}/configuration/dapi/registerUser/request-parameters.adoc[]
=== Response Fields
include::{snippets}/configuration/dapi/registerUser/response-fields.adoc[]
=== Sample Response
include::{snippets}/configuration/dapi/registerUser/response-body.adoc[]
== List available DAPI databases
List available DAPI databases.
=== CURL sample
include::{snippets}/configuration/dapi/list_database/curl-request.adoc[]
=== Response Fields
include::{snippets}/configuration/dapi/list_database/response-fields.adoc[]
=== Sample Response
include::{snippets}/configuration/dapi/list_database/response-body.adoc[]
== List available DAPI database releases
List available DAPI databases.
=== CURL sample
include::{snippets}/configuration/dapi/list_release/curl-request.adoc[]
=== Path Parameters
include::{snippets}/configuration/dapi/list_release/path-parameters.adoc[]
=== Response Fields
include::{snippets}/configuration/dapi/list_release/response-fields.adoc[]
=== Sample Response
include::{snippets}/configuration/dapi/list_release/response-body.adoc[]
== Accept DAPI database release license
Accept DAPI database release license.
=== CURL sample
include::{snippets}/configuration/dapi/accept_release_license/curl-request.adoc[]
=== Path Parameters
include::{snippets}/configuration/dapi/accept_release_license/path-parameters.adoc[]
=== Response Fields
include::{snippets}/configuration/dapi/accept_release_license/response-fields.adoc[]
=== Sample Response
include::{snippets}/configuration/dapi/accept_release_license/response-body.adoc[]
......@@ -5,6 +5,8 @@ import static org.junit.Assert.assertTrue;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.*;
......@@ -77,7 +79,7 @@ public class ConfigurationControllerIntegrationTest extends ControllerIntegratio
RequestBuilder request = get("/configuration/");
mockMvc.perform(request)
.andDo(document("projects/project_overlays/get_all_by_creator",
.andDo(document("configuration/details",
configurationFields()))
.andExpect(status().is2xxSuccessful());
}
......@@ -87,7 +89,13 @@ public class ConfigurationControllerIntegrationTest extends ControllerIntegratio
RequestBuilder request = get("/configuration/options/");
String response = mockMvc.perform(request)
.andExpect(status().is2xxSuccessful()).andReturn().getResponse().getContentAsString();
.andExpect(status().is2xxSuccessful())
.andDo(document("configuration/list_options",
responseFields(subsectionWithPath("[]")
.description("list of options")
.type("Array<Option>")).andWithPrefix("[].", configurationOptionFields())))
.andReturn().getResponse().getContentAsString();
JsonArray options = new JsonParser()
.parse(response)
......@@ -98,6 +106,30 @@ public class ConfigurationControllerIntegrationTest extends ControllerIntegratio
}
@Test
public void testSetSmtpPort() throws Exception {
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
Map<String, Object> option = new HashMap<>();
option.put("value", ConfigurationElementType.EMAIL_SMTP_PORT.getDefaultValue());
Map<String, Object> data = new HashMap<>();
data.put("option", option);
String body = new Gson().toJson(data);
RequestBuilder request = patch("/configuration/options/{option}", ConfigurationElementType.EMAIL_SMTP_PORT.name())
.content(body)
.session(session);
mockMvc.perform(request)
.andDo(document("configuration/modify_option",
pathParameters(parameterWithName("option").description("option type")),
requestFields(
fieldWithPath("option.value").description("new option value")
.type("string")),
responseFields(configurationOptionFields())))
.andExpect(status().is2xxSuccessful());
}
@Test
public void accessConfigurationOptionsAsAdmin() throws Exception {
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment