Skip to content
Snippets Groups Projects
Commit dfb3ef09 authored by Dustin Jenkins's avatar Dustin Jenkins
Browse files

Story 1666: Completed merge from nep110

parents 945a9705 3f08cda6
No related branches found
No related tags found
No related merge requests found
...@@ -140,20 +140,21 @@ public class GMSClientTest ...@@ -140,20 +140,21 @@ public class GMSClientTest
try try
{ {
Subject subject = new Subject(); Subject subject = new Subject();
final HttpPrincipal userID = new HttpPrincipal("test"); final HttpPrincipal test1UserID = new HttpPrincipal("test");
subject.getPrincipals().add(userID); 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>() Subject.doAs(subject, new PrivilegedExceptionAction<Object>()
{ {
@Override @Override
public Object run() throws Exception 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(userID, Role.MEMBER); List<Group> initial = client.getCachedGroups(test1UserID, Role.MEMBER);
Assert.assertNull("Cache should be null", initial); Assert.assertNull("Cache should be null", initial);
List<Group> expected = new ArrayList<Group>(); List<Group> expected = new ArrayList<Group>();
...@@ -162,18 +163,56 @@ public class GMSClientTest ...@@ -162,18 +163,56 @@ public class GMSClientTest
expected.add(group1); expected.add(group1);
expected.add(group2); expected.add(group2);
client.setCachedGroups(userID, expected, Role.MEMBER); client.setCachedGroups(test1UserID, expected, Role.MEMBER);
List<Group> actual = client.getCachedGroups(userID, Role.MEMBER); List<Group> actual = client.getCachedGroups(test1UserID, Role.MEMBER);
Assert.assertEquals("Wrong cached groups", expected, actual); Assert.assertEquals("Wrong cached groups", expected, actual);
// check against another role // check against another role
actual = client.getCachedGroups(userID, Role.OWNER); actual = client.getCachedGroups(test1UserID, Role.OWNER);
Assert.assertNull("Cache should be null", actual); Assert.assertNull("Cache should be null", actual);
// check against another userid // check against another userid
final HttpPrincipal userID2 = new HttpPrincipal("test2"); final HttpPrincipal anotherUserID = new HttpPrincipal("anotheruser");
actual = client.getCachedGroups(userID2, Role.MEMBER); actual = client.getCachedGroups(anotherUserID, 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); Assert.assertNull("Cache should be null", actual);
return null; return null;
...@@ -181,12 +220,8 @@ public class GMSClientTest ...@@ -181,12 +220,8 @@ public class GMSClientTest
}); });
// do the same without a subject // 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(userID, Role.MEMBER); List<Group> initial = client.getCachedGroups(test1UserID, Role.MEMBER);
Assert.assertNull("Cache should be null", initial); Assert.assertNull("Cache should be null", initial);
List<Group> newgroups = new ArrayList<Group>(); List<Group> newgroups = new ArrayList<Group>();
...@@ -195,9 +230,9 @@ public class GMSClientTest ...@@ -195,9 +230,9 @@ public class GMSClientTest
newgroups.add(group1); newgroups.add(group1);
newgroups.add(group2); newgroups.add(group2);
client.setCachedGroups(userID, newgroups, Role.MEMBER); client.setCachedGroups(test1UserID, newgroups, Role.MEMBER);
List<Group> actual = client.getCachedGroups(userID, Role.MEMBER); List<Group> actual = client.getCachedGroups(test1UserID, Role.MEMBER);
Assert.assertNull("Cache should still be null", actual); Assert.assertNull("Cache should still be null", actual);
} }
catch (Throwable t) catch (Throwable t)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment