-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathAuthorizerTest.java
More file actions
59 lines (48 loc) · 2.02 KB
/
AuthorizerTest.java
File metadata and controls
59 lines (48 loc) · 2.02 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* Copyright (c) restSQL Project Contributors. Licensed under MIT. */
package org.restsql.security;
import org.junit.BeforeClass;
import org.junit.Test;
import org.restsql.core.Request;
/**
* Tests default implementation of authorizer.
*
* @author Mark Sawers
*/
public class AuthorizerTest extends BaseAuthorizerTest {
private static Authorizer authorizer;
@BeforeClass
public static void classSetUp() {
authorizer = SecurityFactory.getAuthorizer();
}
@Test
public void testIsAuthorized_ForWildcardResourceWithAuthorizedAction() {
assertAuthorized(authorizer, "all", Request.Type.SELECT, "SingleTable");
assertAuthorized(authorizer, "all", Request.Type.DELETE, "SingleTable");
assertAuthorized(authorizer, "all", Request.Type.UPDATE, "HierManyToMany");
assertAuthorized(authorizer, "readonly", Request.Type.SELECT, "Fabricated");
}
@Test
public void testIsAuthorized_ForWildcardResourceWithUnauthorizedAction() {
assertUnauthorized(authorizer, "limited", Request.Type.DELETE, "SingleTable");
assertUnauthorized(authorizer, "limited", Request.Type.UPDATE, "Fabricated");
}
@Test
public void testIsAuthorized_ForSpecificResourceWithAuthorizedAction() {
assertAuthorized(authorizer, "limited", Request.Type.INSERT, "SingleTable");
assertAuthorized(authorizer, "limited", Request.Type.UPDATE, "SingleTable");
assertAuthorized(authorizer, "all", Request.Type.UPDATE, "FlatOneToOne");
}
@Test
public void testIsAuthorized_ForSpecificResourceWithUnauthorizedRole() {
assertUnauthorized(authorizer, "InvalidRole", Request.Type.DELETE, "SingleTable");
}
@Test
public void testIsAuthorized_ForSpecificResourceWithUnauthorizedAction() {
assertUnauthorized(authorizer, "limited", Request.Type.DELETE, "SingleTable");
assertUnauthorized(authorizer, "readonly", Request.Type.INSERT, "FlatOneToOne");
}
@Test
public void testIsAuthorized_ForSpecificResourceNotFound() {
assertUnauthorized(authorizer, "limited", Request.Type.INSERT, "InvalidResource");
}
}