Skip to content
Snippets Groups Projects
Commit 7d8d32c5 authored by Jeff Burke's avatar Jeff Burke
Browse files

Merge branch 's1651' of ssh://mach16/usr/cadc/dev/git/wopencadc into s1651

parents 1e40e7b4 4ada8fb9
No related branches found
No related tags found
No related merge requests found
......@@ -143,4 +143,22 @@ public class User<T extends Principal>
return getClass().getSimpleName() + "[" + userID.getName() + "]";
}
public <S extends UserDetails> Set<S> getDetails(
final Class<S> userDetailsClass)
{
final Set<S> matchedDetails = new HashSet<S>();
for (final UserDetails ud : details)
{
if (ud.getClass() == userDetailsClass)
{
// This casting shouldn't happen, but it's the only way to
// do this without a lot of work.
// jenkinsd 2014.09.26
matchedDetails.add((S) ud);
}
}
return matchedDetails;
}
}
......@@ -67,9 +67,7 @@
************************************************************************
*/package ca.nrc.cadc.ac;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import javax.security.auth.x500.X500Principal;
......@@ -200,4 +198,19 @@ public class UserTest
}
assertTrue(thrown);
}
@Test
public void getDetails() throws Exception
{
final User<HttpPrincipal> testSubject =
new User<HttpPrincipal>(new HttpPrincipal("test"));
testSubject.details.add(new PersonalDetails("First", "Last"));
assertTrue("Should be empty.",
testSubject.getDetails(PosixDetails.class).isEmpty());
assertEquals("Should be 1.", 1,
testSubject.getDetails(PersonalDetails.class).size());
}
}
......@@ -110,7 +110,8 @@ public class GMSClientTest
subject.getPrincipals().add(userID);
RegistryClient regClient = new RegistryClient();
URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI));
URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI),
"https");
GMSClient client = new GMSClient(baseURL.toString());
Assert.assertFalse(client.userIsSubject(null, null));
......@@ -148,7 +149,8 @@ public class GMSClientTest
public Object run() throws Exception
{
RegistryClient regClient = new RegistryClient();
URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI));
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);
......@@ -180,7 +182,8 @@ public class GMSClientTest
// do the same without a subject
RegistryClient regClient = new RegistryClient();
URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI));
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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment