Skip to content

Commit

Permalink
adding boutiques support in api + correcting api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
axlbonnet committed Sep 30, 2024
1 parent 56ec279 commit 16c7654
Show file tree
Hide file tree
Showing 77 changed files with 4,835 additions and 778 deletions.
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ knowledge of the CeCILL-B license and that you accept its terms.
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.org.webcompere</groupId>
<artifactId>system-stubs-jupiter</artifactId>
<version>2.1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
Expand Down Expand Up @@ -184,6 +190,12 @@ knowledge of the CeCILL-B license and that you accept its terms.
<version>4.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
Expand Down
27 changes: 15 additions & 12 deletions vip-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,6 @@ knowledge of the CeCILL-B license and that you accept its terms.
<version>${keycloak.version}</version>
</dependency>

<!-- Json mapping library -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
</dependency>

<!-- Validation implementation -->
<dependency>
<groupId>org.hibernate</groupId>
Expand Down Expand Up @@ -173,6 +161,21 @@ knowledge of the CeCILL-B license and that you accept its terms.

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>itest</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,10 @@ public void addCorsMappings(CorsRegistry registry) {
}

/*
to verify that the proxy ist still valid each day
to verify that the proxy is still valid each day
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(vipConfigurer);
}

@Bean
public ObjectMapper objectMapper() {
return Jackson2ObjectMapperBuilder.json().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.stereotype.Service;

@Service
Expand Down Expand Up @@ -60,6 +61,9 @@ private User signin(String username, String password) throws ApiException {
logger.info("Credentials OK for " + username);
return user;
} catch (BusinessException e) {
if (e.getMessage().startsWith("Authentication failed")) {
throw new ApiException(ApiException.ApiError.BAD_CREDENTIALS);
}
throw new ApiException("Authentication Error", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ public String initExecution(Execution execution)
}
String resultsLocation = execution.getResultsLocation();
if (resultsLocation != null) {
inputMap.put(CoreConstants.RESULTS_DIRECTORY_PARAM_NAME,
resultsLocation);
inputMap.put(CoreConstants.RESULTS_DIRECTORY_PARAM_NAME, resultsLocation);
}

checkInputExecNameIsValid(execution.getName());
Expand Down Expand Up @@ -326,39 +325,35 @@ private String initExecution(String pipelineId,
// Check that all pipeline inputs are present
Pipeline p = pipelineBusiness.getPipelineWithResultsDirectory(pipelineId);
for (PipelineParameter pp : p.getParameters()) {
// always true on vip
if (pp.isReturnedValue()) {
continue;
}
// pp is an input
if (!(inputValues.get(pp.getName()) == null)) {
// ok if input is present
if ( inputValues.get(pp.getName()) != null) {
continue;
}
// pp is an empty input
// then ok if input has a default value (and we set it)
// beware : with gwendia, optional always have an defaultValue (either defined or No_Value_Provided)
if (pp.getDefaultValue() != null) {
inputValues.put(pp.getName(), pp.getDefaultValue().toString());
continue;
}
// pp is an empty input with no default value
// then ok if it is optional
// beware, with gwendia it should not be possible to enter this case (see previous condition)
if (pp.isOptional()) {
inputValues.put("no", pp.getDefaultValue().toString());//that's how optional values are handled in VIP
continue;
}
// pp is an empty input with no default value and it is not optional
logger.error("Error initialising {}, missing {} parameter",
pipelineId, pp.getName());
throw new ApiException("Parameter " + pp.getName() + " is empty while it is not optional and it has no default value.");
// error : pp is an empty input with no default value and it is not optional
logger.error("Error initialising {}, missing {} parameter", pipelineId, pp.getName());
throw new ApiException(ApiException.ApiError.INPUT_FIELD_MISSING, pp.getName());
}

boolean hasInputResultsDirectory =
inputValues.containsKey(
CoreConstants.RESULTS_DIRECTORY_PARAM_NAME);

boolean hasPipelineResultsDirectory =
p.getParameters().stream().anyMatch(
param ->
boolean inputsContainsResultsDirectoryInput = inputValues.containsKey(CoreConstants.RESULTS_DIRECTORY_PARAM_NAME);
boolean pipelineHasResultsDirectoryInput = p.getParameters().stream().anyMatch(param ->
param.getName().equals(CoreConstants.RESULTS_DIRECTORY_PARAM_NAME));

if (hasInputResultsDirectory && !hasPipelineResultsDirectory) {
if (inputsContainsResultsDirectoryInput && ! pipelineHasResultsDirectoryInput) {
logger.error("Missing results-directory for {}", pipelineId);
throw new ApiException(
"Input has parameter results-directory but it is not defined in pipeline.");
Expand Down
Loading

0 comments on commit 16c7654

Please sign in to comment.