File tree Expand file tree Collapse file tree
src/test/java/eu/openanalytics/containerproxy/test/auth Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments