-
Notifications
You must be signed in to change notification settings - Fork 4
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
13 changed files
with
232 additions
and
17 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
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
11 changes: 6 additions & 5 deletions
11
server/src/test/java/access/cron/IdPMetaDataResolverTest.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
23 changes: 23 additions & 0 deletions
23
server/src/test/java/access/security/ExtendedInMemoryUserDetailsManagerTest.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,23 @@ | ||
package access.security; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.security.core.userdetails.UserDetails; | ||
import org.springframework.security.core.userdetails.UsernameNotFoundException; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
class ExtendedInMemoryUserDetailsManagerTest { | ||
|
||
private final RemoteUser remoteUser = new RemoteUser("user", "password", List.of(Scope.profile)) ; | ||
private final ExtendedInMemoryUserDetailsManager userDetailsManager = | ||
new ExtendedInMemoryUserDetailsManager(List.of(remoteUser)); | ||
|
||
@Test | ||
void loadUserByUsername() { | ||
assertThrows(UsernameNotFoundException.class, () -> userDetailsManager.loadUserByUsername("nope")); | ||
|
||
RemoteUser user = (RemoteUser) userDetailsManager.loadUserByUsername("user"); | ||
assertNotEquals(remoteUser, user); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
server/src/test/java/access/security/LocalDevelopmentAuthenticationFilterTest.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,31 @@ | ||
package access.security; | ||
|
||
import jakarta.servlet.FilterChain; | ||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.ServletRequest; | ||
import jakarta.servlet.ServletResponse; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.mock.web.MockFilterChain; | ||
import org.springframework.mock.web.MockHttpServletRequest; | ||
import org.springframework.mock.web.MockHttpServletResponse; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class LocalDevelopmentAuthenticationFilterTest { | ||
|
||
private final LocalDevelopmentAuthenticationFilter authenticationFilter = new LocalDevelopmentAuthenticationFilter(); | ||
|
||
@Test | ||
void doFilter() throws ServletException, IOException { | ||
ServletRequest request = new MockHttpServletRequest(); | ||
ServletResponse response = new MockHttpServletResponse(); | ||
FilterChain filterChain = new MockFilterChain(); | ||
authenticationFilter.doFilter(request, response, filterChain); | ||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
assertNotNull(authentication); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
server/src/test/java/access/security/RemoteUserPermissionsTest.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,23 @@ | ||
package access.security; | ||
|
||
import access.exception.UserRestrictionException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
class RemoteUserPermissionsTest { | ||
|
||
@Test | ||
void assertScopeAccess() { | ||
assertThrows(UserRestrictionException.class, () -> RemoteUserPermissions.assertScopeAccess(null)); | ||
assertThrows(UserRestrictionException.class, () -> RemoteUserPermissions.assertScopeAccess(new RemoteUser(), Scope.profile)); | ||
|
||
RemoteUserPermissions.assertScopeAccess(new RemoteUser()); | ||
RemoteUserPermissions.assertScopeAccess( | ||
new RemoteUser("user", "secret", List.of(Scope.profile)), Scope.profile); | ||
|
||
} | ||
|
||
} |
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
Oops, something went wrong.