Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
3b763c30
Commit
3b763c30
authored
Jul 10, 2020
by
Piotr Gawron
Browse files
documentation for dapi configuration API calls
parent
49349d83
Pipeline
#29668
passed with stage
in 13 minutes and 7 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
annotation/src/main/java/lcsb/mapviewer/annotation/services/dapi/DapiConnectorImpl.java
View file @
3b763c30
...
...
@@ -220,7 +220,6 @@ public class DapiConnectorImpl extends CachableInterface implements DapiConnecto
List
<
String
>
result
=
new
ArrayList
<>();
String
url
=
DAPI_BASE_URL
+
"database/"
;
String
content
=
getWebPageDownloader
().
getFromNetwork
(
url
);
logger
.
debug
(
content
);
JsonArray
array
=
new
JsonParser
()
.
parse
(
content
)
.
getAsJsonObject
()
...
...
web/src/main/asciidoc/configuration.adoc
View file @
3b763c30
...
...
@@ -66,16 +66,10 @@ include::{snippets}/configuration/dapi/details/response-body.adoc[]
Creates new DAPI user in the https://dapi.lcsb.uni.lu/ system.
=== CURL sample
include::{snippets}/configuration/dapi/register
U
ser/curl-request.adoc[]
include::{snippets}/configuration/dapi/register
_u
ser/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[]
=== Request Fields
include::{snippets}/configuration/dapi/register_user/request-fields.adoc[]
== List available DAPI databases
...
...
@@ -116,10 +110,3 @@ 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[]
web/src/test/java/lcsb/mapviewer/web/ConfigurationControllerIntegrationTest.java
View file @
3b763c30
...
...
@@ -22,6 +22,7 @@ import org.springframework.mock.web.MockHttpSession;
import
org.springframework.restdocs.payload.FieldDescriptor
;
import
org.springframework.restdocs.payload.ResponseFieldsSnippet
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.web.servlet.RequestBuilder
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -38,6 +39,7 @@ import lcsb.mapviewer.services.interfaces.IUserService;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Transactional
@Rollback
@ActiveProfiles
(
"webCtdTestProfile"
)
public
class
ConfigurationControllerIntegrationTest
extends
ControllerIntegrationTest
{
private
static
final
String
TEST_USER_PASSWORD
=
"test_pass"
;
private
static
final
String
TEST_USER_LOGIN
=
"test_user"
;
...
...
@@ -173,6 +175,10 @@ public class ConfigurationControllerIntegrationTest extends ControllerIntegratio
RequestBuilder
request
=
get
(
"/configuration/dapi/"
);
mockMvc
.
perform
(
request
)
.
andDo
(
document
(
"configuration/dapi/details"
,
responseFields
(
subsectionWithPath
(
"validConnection"
)
.
description
(
"is the DAPI connection configured properly"
)
.
type
(
"boolean"
))))
.
andExpect
(
status
().
is2xxSuccessful
());
}
...
...
@@ -181,25 +187,67 @@ public class ConfigurationControllerIntegrationTest extends ControllerIntegratio
RequestBuilder
request
=
get
(
"/configuration/dapi/database/"
);
mockMvc
.
perform
(
request
)
.
andDo
(
document
(
"configuration/dapi/list_database"
,
responseFields
(
fieldWithPath
(
"[]"
)
.
description
(
"list of available databases"
)
.
type
(
"Array"
),
fieldWithPath
(
"[].name"
)
.
description
(
"name of the database"
)
.
type
(
"string"
))))
.
andExpect
(
status
().
is2xxSuccessful
());
}
@Test
public
void
getDapiDrugBankReleaseConfiguration
()
throws
Exception
{
RequestBuilder
request
=
get
(
"/configuration/dapi/database/
DrugBank/release/
"
);
RequestBuilder
request
=
get
(
"/configuration/dapi/database/
{database}/release/"
,
"DrugBank
"
);
mockMvc
.
perform
(
request
)
.
andDo
(
document
(
"configuration/dapi/list_release"
,
pathParameters
(
parameterWithName
(
"database"
).
description
(
"database name"
)),
responseFields
(
fieldWithPath
(
"[]"
)
.
description
(
"list of available releases"
)
.
type
(
"Array"
),
fieldWithPath
(
"[].licenseUrl"
)
.
description
(
"url with the content of license used for this release"
)
.
type
(
"string"
),
fieldWithPath
(
"[].licenseContent"
)
.
description
(
"text content of license used for this release"
)
.
type
(
"string"
),
fieldWithPath
(
"[].name"
)
.
description
(
"version of the database release"
)
.
type
(
"string"
),
fieldWithPath
(
"[].accepted"
)
.
description
(
"was this release accepted by currently logged in DAPI user"
)
.
type
(
"boolean"
))))
.
andExpect
(
status
().
is2xxSuccessful
());
}
@Test
public
void
acceptLicenseReleaseWithoutAccess
()
throws
Exception
{
RequestBuilder
request
=
post
(
"/configuration/dapi/database/DrugBank/release/5.1:acceptLicense"
);
RequestBuilder
request
=
post
(
"/configuration/dapi/database/{database}/release/{release}:acceptLicense"
,
"DrugBank"
,
"5.1"
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isForbidden
());
}
@Test
public
void
acceptLicenseReleaseWithAccess
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
BUILT_IN_TEST_ADMIN_LOGIN
,
BUILT_IN_TEST_ADMIN_PASSWORD
);
RequestBuilder
request
=
post
(
"/configuration/dapi/database/{database}/release/{release}:acceptLicense"
,
"DrugBank"
,
"5.1"
).
session
(
session
);
mockMvc
.
perform
(
request
)
.
andDo
(
document
(
"configuration/dapi/accept_release_license"
,
pathParameters
(
parameterWithName
(
"database"
).
description
(
"database name"
),
parameterWithName
(
"release"
).
description
(
"version of the database"
))))
.
andExpect
(
status
().
is2xxSuccessful
());
}
@Test
public
void
testRegisterExistingDapiUser
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
BUILT_IN_TEST_ADMIN_LOGIN
,
BUILT_IN_TEST_ADMIN_PASSWORD
);
...
...
@@ -207,19 +255,20 @@ public class ConfigurationControllerIntegrationTest extends ControllerIntegratio
UserDto
user
=
new
UserDto
();
user
.
setLogin
(
"admin"
);
user
.
setPassword
(
"admin"
);
user
.
set
Login
(
"piotr.gawron@uni.lu"
);
user
.
set
Email
(
"piotr.gawron@uni.lu"
);
RequestBuilder
request
=
post
(
"/configuration/dapi:registerUser"
)
.
content
(
new
ObjectMapper
().
writeValueAsString
(
user
))
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
session
(
session
);
try
{
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isConflict
());
}
catch
(
Exception
e
)
{
System
.
exit
(
0
);
throw
e
;
}
mockMvc
.
perform
(
request
)
.
andDo
(
document
(
"configuration/dapi/register_user"
,
requestFields
(
fieldWithPath
(
"login"
).
description
(
"user login"
).
type
(
"string"
),
fieldWithPath
(
"password"
).
description
(
"user password"
).
type
(
"string"
),
fieldWithPath
(
"email"
).
description
(
"email address"
).
type
(
"string"
))))
.
andExpect
(
status
().
isConflict
());
}
private
ResponseFieldsSnippet
configurationFields
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment