-
Notifications
You must be signed in to change notification settings - Fork 682
/
IsRememberedAuthorizerTests.java
44 lines (37 loc) · 1.2 KB
/
IsRememberedAuthorizerTests.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package org.pac4j.core.authorization.authorizer;
import org.junit.Test;
import org.pac4j.core.context.MockWebContext;
import org.pac4j.core.exception.HttpAction;
import org.pac4j.core.profile.AnonymousProfile;
import org.pac4j.core.util.TestsHelper;
import static org.junit.Assert.assertFalse;
/**
* Tests {@link IsRememberedAuthorizer}.
*
* @author Jerome Leleu
* @since 1.9.0
*/
public final class IsRememberedAuthorizerTests extends IsAuthenticatedAuthorizerTests {
@Override
protected Authorizer newAuthorizer() {
return new IsRememberedAuthorizer<>();
}
@Override
protected boolean isRemembered() {
return true;
}
@Override
@Test
public void testAnonymousProfileRedirectionUrl() {
profiles.add(new AnonymousProfile());
((IsRememberedAuthorizer) authorizer).setRedirectionUrl(PAC4J_URL);
TestsHelper.expectException(() -> authorizer.isAuthorized(MockWebContext.create(), profiles), HttpAction.class,
"Performing a 302 HTTP action");
}
@Test
public void testCommonRmeProfile() {
profile.setRemembered(false);
profiles.add(profile);
assertFalse(authorizer.isAuthorized(null, profiles));
}
}