Skip to content

Commit bd0ccd6

Browse files
committed
Ref #33886: validate access-expression for none auth
1 parent c086a62 commit bd0ccd6

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/test/java/eu/openanalytics/containerproxy/test/auth/AccessControlServiceTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,27 @@ public void anonymousAccessTest() {
105105
AccessControl proxyAccessControl = new AccessControl();
106106
proxyAccessControl.setGroups(new String[]{"myGroup"});
107107

108-
// when anonymous -> has access
108+
// when anonymous -> has no access
109109
Authentication anonymousAuth = mock(AnonymousAuthenticationToken.class);
110-
Assertions.assertTrue(accessControlService.canAccess(anonymousAuth, createProxySpec(proxyAccessControl)));
110+
Assertions.assertFalse(accessControlService.canAccess(anonymousAuth, createProxySpec(proxyAccessControl)));
111111

112112
// when not-anonymous -> has no access
113113
Authentication auth = mock(Authentication.class);
114114
Assertions.assertFalse(accessControlService.canAccess(auth, createProxySpec(proxyAccessControl)));
115115

116116
// when spec has no Access Control -> has access
117117
Assertions.assertTrue(accessControlService.canAccess(anonymousAuth, createProxySpec(null)));
118+
119+
proxyAccessControl = new AccessControl();
120+
proxyAccessControl.setExpression("#{false}");
121+
122+
// when spec has 'false' expression -> has no access
123+
Assertions.assertFalse(accessControlService.canAccess(anonymousAuth, createProxySpec(proxyAccessControl)));
124+
125+
proxyAccessControl.setExpression("#{true}");
126+
127+
// when spec has 'true' expression -> has access
128+
Assertions.assertTrue(accessControlService.canAccess(anonymousAuth, createProxySpec(proxyAccessControl)));
118129
}
119130

120131
@Test

0 commit comments

Comments
 (0)