-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...main/java/edu/internet2/tier/shibboleth/admin/ui/security/controller/UsersController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.security.controller; | ||
|
||
import edu.internet2.tier.shibboleth.admin.ui.security.model.User; | ||
import edu.internet2.tier.shibboleth.admin.ui.security.repository.UserRepository; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Implementation of the REST resource endpoints exposing system users. | ||
* | ||
* @author Dmitriy Kopylenko | ||
*/ | ||
@RestController | ||
@RequestMapping("/api/security/users") | ||
public class UsersController { | ||
|
||
private UserRepository userRepository; | ||
|
||
public UsersController(UserRepository userRepository) { | ||
this.userRepository = userRepository; | ||
} | ||
|
||
@GetMapping | ||
List<User> getAll() { | ||
return userRepository.findAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...rnet2/tier/shibboleth/admin/ui/security/controller/UsersControllerIntegrationTests.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.security.controller | ||
|
||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.boot.test.web.client.TestRestTemplate | ||
import org.springframework.test.context.ActiveProfiles | ||
import spock.lang.Specification | ||
|
||
/** | ||
* @author Dmitriy Kopylenko | ||
*/ | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@ActiveProfiles(["no-auth", "dev"]) | ||
class UsersControllerIntegrationTests extends Specification { | ||
|
||
@Autowired | ||
private TestRestTemplate restTemplate | ||
|
||
static RESOURCE_URI = '/api/security/users' | ||
|
||
def "GET users"() { | ||
when: 'GET request is made for ALL users in the system' | ||
def result = this.restTemplate.getForEntity(RESOURCE_URI, Object) | ||
|
||
then: "Request completed successfully" | ||
result.statusCodeValue == 200 | ||
result.body[0].username == 'admin' | ||
result.body[0].roles[0].name == 'ROLE_ADMIN' | ||
} | ||
} |