Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a40fbbf3 authored by Wylem Bars's avatar Wylem Bars
Browse files

IUAINFRA-52 | Use real implementation for rest service

parent a2933aaf
No related branches found
No related tags found
1 merge request!2Feature/iuainfra 52
Pipeline #165425 failed
Showing with 39 additions and 17 deletions
......@@ -55,7 +55,7 @@ public class TokenGenerator {
throw new TokenRequestException("Unsupported issuer");
}
if (accessTokenRequest.getAudience() ==null || accessTokenRequest.getAudience().isEmpty()) {
if (accessTokenRequest.getAudience() == null || accessTokenRequest.getAudience().isEmpty()) {
throw new TokenRequestException("Audience is null or empty");
}
......
Put here test classes for adapter layer.
\ No newline at end of file
package net.ihe.gazelle.app.accesstokenproviderapi.application;
import net.ihe.gazelle.app.audienceretriever.application.AudienceSecretRetriever;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
class DummyAuthzServerSoapuiTest {
......
Put here test classes for application layer.
\ No newline at end of file
Put here test classes for business layer.
\ No newline at end of file
......@@ -2,26 +2,47 @@ package net.ihe.gazelle.app.dummyauthorizationserverservice.adapter;
import net.ihe.gazelle.app.accesstokenproviderapi.application.DummyAuthzServer;
import net.ihe.gazelle.app.accesstokenproviderapi.application.DummyAuthzServerSoapui;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.ext.Provider;
import java.nio.charset.StandardCharsets;
/**
* Service for Mock Access Token Provider.
*/
@Provider
@Path(value="/mock-token")
@Path(value = "/mock-token")
public class AuthorizationServerService {
private DummyAuthzServer dummyAuthzServer;
public AuthorizationServerService() {
dummyAuthzServer = new DummyAuthzServerSoapui();
}
/**
* Setter for the dummyAuthzServer property.
*
* @param dummyAuthzServer value to set to the property.
*/
public void setDummyAuthzServer(DummyAuthzServer dummyAuthzServer) {
this.dummyAuthzServer = dummyAuthzServer;
}
/**
* get a dummy access token
*
* @param userId
* @param audienceId
* @param purposeOfUse
* @param resourceId
* @return an access token
*/
@GET
public byte[] getAccessToken(String userId, String audienceId, String purposeOfUse, String resourceId){
// TODO Put real implementation but it doesn't work right now
// DummyAuthzServer dummyAuthzServer = new DummyAuthzServerSoapui();
DummyAuthzServer dummyAuthzServer = new DummyAuthzServer() {
@Override
public byte[] getAccessToken(String userId, String audienceId, String purposeOfUse, String resourceId) {
return "Tartes aux pommes".getBytes(StandardCharsets.UTF_8);
}
};
public byte[] getAccessToken(@QueryParam("userId") String userId, @QueryParam("audienceId") String audienceId,
@QueryParam("purposeOfUse") String purposeOfUse, @QueryParam("resourceId") String resourceId) {
return dummyAuthzServer.getAccessToken(userId, audienceId, purposeOfUse, resourceId);
}
......
......@@ -3,7 +3,7 @@ package net.ihe.gazelle.app.dummyauthorizationserverservice.adapter;
import net.ihe.gazelle.app.accesstokenproviderapi.application.DummyAuthzServerSoapui;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNotNull;
class AuthorizationServerServiceTest {
......@@ -16,6 +16,10 @@ class AuthorizationServerServiceTest {
@Test
public void getAccessToken() {
AuthorizationServerService authorizationServerService = new AuthorizationServerService();
DummyAuthzServerSoapui dummyAuthzServer = new DummyAuthzServerSoapui();
dummyAuthzServer.setAudienceSecretRetriever((String audience) -> "secret");
authorizationServerService.setDummyAuthzServer(dummyAuthzServer);
assertNotNull(authorizationServerService.getAccessToken(SUBJECT, AUDIENCE, null, null));
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment