Skip to content

Commit

Permalink
Added: Test endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
djuarezgf committed Dec 30, 2023
1 parent 52b7fe5 commit 3d74ee9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Action names
- Module names
- Http Method and Params for Actions
- Test endpoint
2 changes: 2 additions & 0 deletions src/main/java/de/samply/app/ProjectManagerConst.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class ProjectManagerConst {

// REST Services
public final static String INFO = "/info";
public final static String TEST = "/test";
public final static String ACTIONS = "/actions";
public final static String SET_DEVELOPER_USER = "/set-developer-user";
public final static String SET_PILOT_USER = "/set-pilot-user";
Expand Down Expand Up @@ -174,5 +175,6 @@ public class ProjectManagerConst {
public final static int PROJECT_CODE_SIZE = 20;
public final static int QUERY_CODE_SIZE = 20;
public final static String NO_BRIDGEHEAD = "NONE";
public final static String THIS_IS_A_TEST = "This is a test";

}
5 changes: 5 additions & 0 deletions src/main/java/de/samply/app/ProjectManagerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public ResponseEntity<String> info() {
return new ResponseEntity<>(projectVersion, HttpStatus.OK);
}

@GetMapping(value = ProjectManagerConst.TEST)
public ResponseEntity<String> test() {
return new ResponseEntity<>(ProjectManagerConst.THIS_IS_A_TEST, HttpStatus.OK);
}

@GetMapping(value = ProjectManagerConst.ACTIONS, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> fetchActions(
@ProjectCode @RequestParam(name = ProjectManagerConst.PROJECT_CODE, required = false) String projectCode,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/samply/db/model/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class Project {
@Enumerated(EnumType.STRING)
private ProjectState state;

@ManyToOne
@OneToOne
@JoinColumn(name = "query_id")
private Query query;

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/de/samply/security/SecurityConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
}

private AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry addAuthorityMapping(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry authorization) {
// Services without authentication required
authorization.requestMatchers(new AntPathRequestMatcher(ProjectManagerConst.INFO, "GET")).permitAll();
// Services with authentication required
Map<String, MethodRoles> pathRolesMap = RolesExtractor.extractPathRolesMap();
pathRolesMap.keySet().forEach(path -> authorization
.requestMatchers(new AntPathRequestMatcher(path, pathRolesMap.get(path).httpMethod()))
Expand Down

0 comments on commit 3d74ee9

Please sign in to comment.