-
Notifications
You must be signed in to change notification settings - Fork 682
/
CheckProfileTypeAuthorizerTests.java
41 lines (34 loc) · 1.2 KB
/
CheckProfileTypeAuthorizerTests.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
package org.pac4j.core.authorization.authorizer;
import org.junit.Test;
import org.pac4j.core.profile.CommonProfile;
import org.pac4j.core.profile.UserProfile;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* Tests {@link CheckProfileTypeAuthorizer}.
*
* @author Jerome Leleu
* @since 1.8.1
*/
public final class CheckProfileTypeAuthorizerTests {
class FakeProfile1 extends CommonProfile {
}
class FakeProfile2 extends CommonProfile {
}
@Test
public void testGoodProfile() {
final CheckProfileTypeAuthorizer authorizer = new CheckProfileTypeAuthorizer(FakeProfile1.class, FakeProfile2.class);
final List<UserProfile> profiles = new ArrayList<>();
profiles.add(new FakeProfile1());
assertTrue(authorizer.isAuthorized(null, profiles));
}
@Test
public void testBadProfileType() {
final CheckProfileTypeAuthorizer authorizer = new CheckProfileTypeAuthorizer(FakeProfile1.class);
final List<UserProfile> profiles = new ArrayList<>();
profiles.add(new FakeProfile2());
assertFalse(authorizer.isAuthorized(null, profiles));
}
}