Skip to content

Commit

Permalink
Merge branch 'main' into feature/helm_upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
shijinrajbosch authored Nov 21, 2023
2 parents dcfea5b + fe5ba2f commit 22213ec
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added helm upgrade feature into helm test

## fixed
- Handled UrnSyntaxException.

## 0.2.14
### Added
Expand Down
19 changes: 15 additions & 4 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Security Policy

## Reporting a Vulnerability

Please report a found vulnerability here:
[https://www.eclipse.org/security/](https://www.eclipse.org/security/)
Please do **not** report security vulnerabilities through public GitHub issues.

Please report vulnerabilities to this repository via **GitHub security advisories** instead.

How? Inside affected repository → security tab

for contributor:
→ Report a vulnerability

for committer:
→ advisories → New draft security advisory

In severe cases, you can also report a found vulnerability via mail or eclipse issue here: https://www.eclipse.org/security/

See [Eclipse Foundation Vulnerability Reporting Policy](https://www.eclipse.org/projects/handbook/#vulnerability)
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
import java.util.Map;
import java.util.stream.Collectors;

import org.eclipse.esmf.aspectmodel.urn.UrnSyntaxException;
import org.eclipse.tractusx.semantics.hub.AspectModelNotFoundException;
import org.eclipse.tractusx.semantics.hub.EntityNotFoundException;
import org.eclipse.tractusx.semantics.hub.InvalidAspectModelException;
import org.eclipse.tractusx.semantics.hub.InvalidStateTransitionException;
import org.eclipse.tractusx.semantics.hub.ModelPackageNotFoundException;
import org.eclipse.tractusx.semantics.hub.model.Error;
import org.eclipse.tractusx.semantics.hub.model.ErrorResponse;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -35,14 +43,6 @@
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.method.annotation.MethodArgumentConversionNotSupportedException;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import org.eclipse.tractusx.semantics.hub.AspectModelNotFoundException;
import org.eclipse.tractusx.semantics.hub.EntityNotFoundException;
import org.eclipse.tractusx.semantics.hub.InvalidAspectModelException;
import org.eclipse.tractusx.semantics.hub.InvalidStateTransitionException;

import org.eclipse.tractusx.semantics.hub.ModelPackageNotFoundException;
import org.eclipse.tractusx.semantics.hub.model.Error;
import org.eclipse.tractusx.semantics.hub.model.ErrorResponse;

import jakarta.servlet.http.HttpServletRequest;

Expand Down Expand Up @@ -124,4 +124,12 @@ public ResponseEntity<ErrorResponse> handleInvalidStateTransitionException( fina
.path( request.getRequestURI() ) ), HttpStatus.BAD_REQUEST );
}

@ExceptionHandler( { UrnSyntaxException.class } )
public ResponseEntity<ErrorResponse> handleInvalidStateTransitionException( final HttpServletRequest request, final UrnSyntaxException exception ) {
return new ResponseEntity<>( new ErrorResponse()
.error( new Error()
.message( exception.getMessage() )
.path( request.getRequestURI() ) ), HttpStatus.BAD_REQUEST );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -923,4 +923,15 @@ public void testDependentModelBAMM() throws Exception {
private static String toMovementUrn(String urn){
return urn + "Movement";
}

@Test
public void testGetModelByURNWithInvalidURN() throws Exception {
String urnPrefix = "urn:invalid";
mvc.perform( MockMvcRequestBuilders.get( "/api/v1/models/{urn}", urnPrefix ).with( jwtTokenFactory.allRoles() ) )
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isBadRequest() )
.andExpect( jsonPath( "$.error.message", is(
"The URN must consist of at least 5 sections adhering to the following schema: "
+ "urn:samm:<organisation>:<optional>:<version>:<model-name>." ) ) );
}
}

0 comments on commit 22213ec

Please sign in to comment.