Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ac
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OATS-CADC
ac
Commits
dfb3ef09
Commit
dfb3ef09
authored
10 years ago
by
Dustin Jenkins
Browse files
Options
Downloads
Plain Diff
Story 1666: Completed merge from nep110
parents
945a9705
3f08cda6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
projects/cadcAccessControl/test/src/ca/nrc/cadc/ac/client/GMSClientTest.java
+54
-19
54 additions, 19 deletions
...Control/test/src/ca/nrc/cadc/ac/client/GMSClientTest.java
with
54 additions
and
19 deletions
projects/cadcAccessControl/test/src/ca/nrc/cadc/ac/client/GMSClientTest.java
+
54
−
19
View file @
dfb3ef09
...
...
@@ -140,20 +140,21 @@ public class GMSClientTest
try
{
Subject
subject
=
new
Subject
();
final
HttpPrincipal
userID
=
new
HttpPrincipal
(
"test"
);
subject
.
getPrincipals
().
add
(
userID
);
final
HttpPrincipal
test1UserID
=
new
HttpPrincipal
(
"test"
);
subject
.
getPrincipals
().
add
(
test1UserID
);
RegistryClient
regClient
=
new
RegistryClient
();
URL
baseURL
=
regClient
.
getServiceURL
(
new
URI
(
AC
.
GMS_SERVICE_URI
),
"https"
);
final
GMSClient
client
=
new
GMSClient
(
baseURL
.
toString
());
Subject
.
doAs
(
subject
,
new
PrivilegedExceptionAction
<
Object
>()
{
@Override
public
Object
run
()
throws
Exception
{
RegistryClient
regClient
=
new
RegistryClient
();
URL
baseURL
=
regClient
.
getServiceURL
(
new
URI
(
AC
.
GMS_SERVICE_URI
),
"https"
);
GMSClient
client
=
new
GMSClient
(
baseURL
.
toString
());
List
<
Group
>
initial
=
client
.
getCachedGroups
(
u
serID
,
Role
.
MEMBER
);
List
<
Group
>
initial
=
client
.
getCachedGroups
(
test1U
serID
,
Role
.
MEMBER
);
Assert
.
assertNull
(
"Cache should be null"
,
initial
);
List
<
Group
>
expected
=
new
ArrayList
<
Group
>();
...
...
@@ -162,31 +163,65 @@ public class GMSClientTest
expected
.
add
(
group1
);
expected
.
add
(
group2
);
client
.
setCachedGroups
(
u
serID
,
expected
,
Role
.
MEMBER
);
client
.
setCachedGroups
(
test1U
serID
,
expected
,
Role
.
MEMBER
);
List
<
Group
>
actual
=
client
.
getCachedGroups
(
u
serID
,
Role
.
MEMBER
);
List
<
Group
>
actual
=
client
.
getCachedGroups
(
test1U
serID
,
Role
.
MEMBER
);
Assert
.
assertEquals
(
"Wrong cached groups"
,
expected
,
actual
);
// check against another role
actual
=
client
.
getCachedGroups
(
u
serID
,
Role
.
OWNER
);
actual
=
client
.
getCachedGroups
(
test1U
serID
,
Role
.
OWNER
);
Assert
.
assertNull
(
"Cache should be null"
,
actual
);
// check against another userid
final
HttpPrincipal
u
serID
2
=
new
HttpPrincipal
(
"
test2
"
);
actual
=
client
.
getCachedGroups
(
u
serID
2
,
Role
.
MEMBER
);
final
HttpPrincipal
anotherU
serID
=
new
HttpPrincipal
(
"
anotheruser
"
);
actual
=
client
.
getCachedGroups
(
anotherU
serID
,
Role
.
MEMBER
);
Assert
.
assertNull
(
"Cache should be null"
,
actual
);
return
null
;
}
});
subject
=
new
Subject
();
final
HttpPrincipal
test2UserID
=
new
HttpPrincipal
(
"test2"
);
subject
.
getPrincipals
().
add
(
test2UserID
);
// do the same but as a different user
Subject
.
doAs
(
subject
,
new
PrivilegedExceptionAction
<
Object
>()
{
@Override
public
Object
run
()
throws
Exception
{
List
<
Group
>
initial
=
client
.
getCachedGroups
(
test2UserID
,
Role
.
MEMBER
);
Assert
.
assertNull
(
"Cache should be null"
,
initial
);
List
<
Group
>
expected
=
new
ArrayList
<
Group
>();
Group
group1
=
new
Group
(
"1"
);
Group
group2
=
new
Group
(
"2"
);
expected
.
add
(
group1
);
expected
.
add
(
group2
);
client
.
setCachedGroups
(
test2UserID
,
expected
,
Role
.
MEMBER
);
List
<
Group
>
actual
=
client
.
getCachedGroups
(
test2UserID
,
Role
.
MEMBER
);
Assert
.
assertEquals
(
"Wrong cached groups"
,
expected
,
actual
);
// check against another role
actual
=
client
.
getCachedGroups
(
test2UserID
,
Role
.
OWNER
);
Assert
.
assertNull
(
"Cache should be null"
,
actual
);
// check against another userid
final
HttpPrincipal
anotherUserID
=
new
HttpPrincipal
(
"anotheruser"
);
actual
=
client
.
getCachedGroups
(
anotherUserID
,
Role
.
MEMBER
);
Assert
.
assertNull
(
"Cache should be null"
,
actual
);
return
null
;
}
});
// do the same without a subject
RegistryClient
regClient
=
new
RegistryClient
();
URL
baseURL
=
regClient
.
getServiceURL
(
new
URI
(
AC
.
GMS_SERVICE_URI
),
"https"
);
GMSClient
client
=
new
GMSClient
(
baseURL
.
toString
());
List
<
Group
>
initial
=
client
.
getCachedGroups
(
u
serID
,
Role
.
MEMBER
);
List
<
Group
>
initial
=
client
.
getCachedGroups
(
test1U
serID
,
Role
.
MEMBER
);
Assert
.
assertNull
(
"Cache should be null"
,
initial
);
List
<
Group
>
newgroups
=
new
ArrayList
<
Group
>();
...
...
@@ -195,9 +230,9 @@ public class GMSClientTest
newgroups
.
add
(
group1
);
newgroups
.
add
(
group2
);
client
.
setCachedGroups
(
u
serID
,
newgroups
,
Role
.
MEMBER
);
client
.
setCachedGroups
(
test1U
serID
,
newgroups
,
Role
.
MEMBER
);
List
<
Group
>
actual
=
client
.
getCachedGroups
(
u
serID
,
Role
.
MEMBER
);
List
<
Group
>
actual
=
client
.
getCachedGroups
(
test1U
serID
,
Role
.
MEMBER
);
Assert
.
assertNull
(
"Cache should still be null"
,
actual
);
}
catch
(
Throwable
t
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment