-
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
6 changed files
with
59 additions
and
12 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
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
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
53 changes: 53 additions & 0 deletions
53
...u/internet2/tier/shibboleth/admin/ui/security/springsecurity/AdminUserServiceTests.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,53 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.security.springsecurity | ||
|
||
import edu.internet2.tier.shibboleth.admin.ui.security.repository.AdminRoleRepository | ||
import edu.internet2.tier.shibboleth.admin.ui.security.repository.AdminUserRepository | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.context.annotation.Profile | ||
import org.springframework.security.core.userdetails.UsernameNotFoundException | ||
import org.springframework.test.annotation.DirtiesContext | ||
import org.springframework.test.context.ActiveProfiles | ||
import spock.lang.Specification | ||
|
||
/** | ||
* Tests for <code>AdminUserService</code> | ||
* | ||
* @author Dmitriy Kopylenko | ||
*/ | ||
@SpringBootTest | ||
@ActiveProfiles('dev') | ||
class AdminUserServiceTests extends Specification { | ||
|
||
@Autowired | ||
AdminUserService adminUserService | ||
|
||
@Autowired | ||
AdminRoleRepository adminRoleRepository | ||
|
||
@Autowired | ||
AdminUserRepository adminUserRepository | ||
|
||
|
||
def "Loading existing admin user with admin role"() { | ||
given: 'Valid user with admin role is available (loaded by Spring Boot Listener in dev profile)' | ||
def user = adminUserService.loadUserByUsername('admin') | ||
|
||
expect: | ||
user.username == 'admin' | ||
user.password == '{noop}adminpass' | ||
user.getAuthorities().size() == 1 | ||
user.getAuthorities()[0].authority == 'ROLE_ADMIN' | ||
user.enabled | ||
user.accountNonExpired | ||
user.credentialsNonExpired | ||
} | ||
|
||
def "Loading NON-existing admin user with admin role"() { | ||
when: 'Non-existent admin user is tried to be looked up' | ||
adminUserService.loadUserByUsername('nonexisting') | ||
|
||
then: | ||
thrown UsernameNotFoundException | ||
} | ||
} |