Skip to content

Commit

Permalink
Endpoint get users
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Oct 7, 2023
1 parent 471fa53 commit b0d4c9b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mujina-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.openconext</groupId>
<artifactId>mujina</artifactId>
<version>8.0.7</version>
<version>8.0.8</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion mujina-idp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.openconext</groupId>
<artifactId>mujina</artifactId>
<version>8.0.7</version>
<version>8.0.8</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
6 changes: 6 additions & 0 deletions mujina-idp/src/main/java/mujina/api/IdpController.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public void removeAttributeForUser(@PathVariable String name, @PathVariable Stri
"must be created", userName))).getAttributes().remove(name);
}

@GetMapping("/users")
public List<FederatedUserAuthenticationToken> users() {
LOG.info("Request to get users");
return configuration().getUsers();
}

@PutMapping("/users")
public void addUser(@RequestBody User user) {
LOG.info("Request to add user {}", user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void before() throws Exception {
.statusCode(SC_OK);
}

protected CookieFilter login(String username, String password, int statusCode) throws Exception {
protected CookieFilter login(String username, String password, int statusCode) {
CookieFilter cookieFilter = new CookieFilter();

given()
Expand Down
11 changes: 9 additions & 2 deletions mujina-idp/src/test/java/mujina/api/IdpControllerTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mujina.api;

import io.restassured.common.mapper.TypeRef;
import mujina.AbstractIntegrationTest;
import org.junit.Test;

Expand Down Expand Up @@ -57,12 +58,18 @@ public void addUser() {
api(user, "/api/users");

assertTrue(idpConfiguration.getUsers().stream()
.filter(token -> token.getName().equals(user.getName())).findAny().isPresent());
.anyMatch(token -> token.getName().equals(user.getName())));

List<Map<Object, Object>> users = given()
.header("Content-Type", "application/json")
.get("/api/users")
.as(new TypeRef<>() {
});
assertEquals(3, users.size());
}

@Test
public void setAuthenticationMethod() throws Exception {
public void setAuthenticationMethod() {
assertEquals(USER, idpConfiguration.getAuthenticationMethod());

api(ALL.name(), "/api/authmethod");
Expand Down
2 changes: 1 addition & 1 deletion mujina-sp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.openconext</groupId>
<artifactId>mujina</artifactId>
<version>8.0.7</version>
<version>8.0.8</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<groupId>org.openconext</groupId>
<artifactId>mujina</artifactId>
<version>8.0.7</version>
<version>8.0.8</version>
<packaging>pom</packaging>

<parent>
Expand Down

0 comments on commit b0d4c9b

Please sign in to comment.