Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OATS-CADC
ac
Commits
8c7b1018
Commit
8c7b1018
authored
Nov 07, 2016
by
Brian Major
Browse files
issue-10 - removed LocalAuthority from tests
parent
3f22fd66
Changes
8
Hide whitespace changes
Inline
Side-by-side
cadc-access-control-server/src/main/java/ca/nrc/cadc/ac/server/web/WhoAmIServlet.java
View file @
8c7b1018
...
...
@@ -79,13 +79,13 @@ import javax.servlet.http.HttpServlet;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
ca.nrc.cadc.auth.AuthMethod
;
import
ca.nrc.cadc.reg.Standards
;
import
org.apache.log4j.Logger
;
import
ca.nrc.cadc.auth.AuthMethod
;
import
ca.nrc.cadc.auth.AuthenticationUtil
;
import
ca.nrc.cadc.auth.HttpPrincipal
;
import
ca.nrc.cadc.log.ServletLogInfo
;
import
ca.nrc.cadc.reg.Standards
;
import
ca.nrc.cadc.reg.client.LocalAuthority
;
import
ca.nrc.cadc.reg.client.RegistryClient
;
...
...
@@ -154,6 +154,12 @@ public class WhoAmIServlet extends HttpServlet
}
}
public
URI
getServiceURI
(
URI
standard
)
{
LocalAuthority
localAuthority
=
new
LocalAuthority
();
return
localAuthority
.
getServiceURI
(
standard
.
toString
());
}
/**
* Forward on to the Service's user endpoint.
*
...
...
@@ -167,8 +173,7 @@ public class WhoAmIServlet extends HttpServlet
{
final
RegistryClient
registryClient
=
getRegistryClient
();
LocalAuthority
localAuthority
=
new
LocalAuthority
();
URI
umsServiceURI
=
localAuthority
.
getServiceURI
(
Standards
.
UMS_WHOAMI_01
.
toString
());
URI
umsServiceURI
=
getServiceURI
(
Standards
.
UMS_WHOAMI_01
);
log
.
debug
(
"ums service uri: "
+
umsServiceURI
);
final
URL
serviceURL
=
registryClient
.
getServiceURL
(
umsServiceURI
,
Standards
.
UMS_USERS_01
,
AuthMethod
.
CERT
);
...
...
cadc-access-control-server/src/main/java/ca/nrc/cadc/ac/server/web/groups/AbstractGroupAction.java
View file @
8c7b1018
...
...
@@ -69,6 +69,7 @@
package
ca.nrc.cadc.ac.server.web.groups
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.security.AccessControlException
;
import
java.security.Principal
;
import
java.security.PrivilegedActionException
;
...
...
@@ -91,6 +92,7 @@ import ca.nrc.cadc.ac.server.GroupPersistence;
import
ca.nrc.cadc.ac.server.web.SyncOutput
;
import
ca.nrc.cadc.auth.HttpPrincipal
;
import
ca.nrc.cadc.net.TransientException
;
import
ca.nrc.cadc.reg.client.LocalAuthority
;
public
abstract
class
AbstractGroupAction
implements
PrivilegedExceptionAction
<
Object
>
{
...
...
@@ -126,6 +128,12 @@ public abstract class AbstractGroupAction implements PrivilegedExceptionAction<O
this
.
groupPersistence
=
groupPersistence
;
}
public
URI
getServiceURI
(
URI
standard
)
{
LocalAuthority
localAuthority
=
new
LocalAuthority
();
return
localAuthority
.
getServiceURI
(
standard
.
toString
());
}
public
Object
run
()
throws
PrivilegedActionException
{
try
...
...
cadc-access-control-server/src/main/java/ca/nrc/cadc/ac/server/web/groups/AddGroupMemberAction.java
View file @
8c7b1018
...
...
@@ -76,7 +76,6 @@ import ca.nrc.cadc.ac.Group;
import
ca.nrc.cadc.ac.GroupAlreadyExistsException
;
import
ca.nrc.cadc.ac.GroupURI
;
import
ca.nrc.cadc.reg.Standards
;
import
ca.nrc.cadc.reg.client.LocalAuthority
;
public
class
AddGroupMemberAction
extends
AbstractGroupAction
{
...
...
@@ -94,8 +93,7 @@ public class AddGroupMemberAction extends AbstractGroupAction
public
void
doAction
()
throws
Exception
{
Group
group
=
groupPersistence
.
getGroup
(
this
.
groupName
);
LocalAuthority
localAuthority
=
new
LocalAuthority
();
URI
gmsServiceURI
=
localAuthority
.
getServiceURI
(
Standards
.
GMS_GROUPS_01
.
toString
());
URI
gmsServiceURI
=
getServiceURI
(
Standards
.
GMS_GROUPS_01
);
GroupURI
toAddID
=
new
GroupURI
(
gmsServiceURI
.
toString
()
+
"?"
+
this
.
groupMemberName
);
Group
toAdd
=
new
Group
(
toAddID
);
if
(!
group
.
getGroupMembers
().
add
(
toAdd
))
...
...
cadc-access-control-server/src/main/java/ca/nrc/cadc/ac/server/web/groups/RemoveGroupMemberAction.java
View file @
8c7b1018
...
...
@@ -78,7 +78,6 @@ import ca.nrc.cadc.ac.Group;
import
ca.nrc.cadc.ac.GroupNotFoundException
;
import
ca.nrc.cadc.ac.GroupURI
;
import
ca.nrc.cadc.reg.Standards
;
import
ca.nrc.cadc.reg.client.LocalAuthority
;
public
class
RemoveGroupMemberAction
extends
AbstractGroupAction
{
...
...
@@ -97,8 +96,7 @@ public class RemoveGroupMemberAction extends AbstractGroupAction
public
void
doAction
()
throws
Exception
{
Group
group
=
groupPersistence
.
getGroup
(
this
.
groupName
);
LocalAuthority
localAuthority
=
new
LocalAuthority
();
URI
gmsServiceURI
=
localAuthority
.
getServiceURI
(
Standards
.
GMS_GROUPS_01
.
toString
());
URI
gmsServiceURI
=
getServiceURI
(
Standards
.
GMS_GROUPS_01
);
GroupURI
toRemoveID
=
new
GroupURI
(
gmsServiceURI
.
toString
()
+
"?"
+
this
.
groupMemberName
);
Group
toRemove
=
new
Group
(
toRemoveID
);
...
...
cadc-access-control-server/src/test/java/ca/nrc/cadc/ac/server/web/WhoAmIServletTest.java
View file @
8c7b1018
...
...
@@ -91,7 +91,6 @@ import org.junit.Test;
import
ca.nrc.cadc.auth.AuthMethod
;
import
ca.nrc.cadc.auth.HttpPrincipal
;
import
ca.nrc.cadc.reg.Standards
;
import
ca.nrc.cadc.reg.client.LocalAuthority
;
import
ca.nrc.cadc.reg.client.RegistryClient
;
import
ca.nrc.cadc.util.Log4jInit
;
import
ca.nrc.cadc.util.PropertiesReader
;
...
...
@@ -140,6 +139,12 @@ public class WhoAmIServletTest
{
return
subject
;
}
@Override
public
URI
getServiceURI
(
URI
standard
)
{
return
URI
.
create
(
"ivo://example.org/ums"
);
}
};
final
HttpServletRequest
mockRequest
=
...
...
@@ -155,8 +160,7 @@ public class WhoAmIServletTest
mockResponse
.
sendRedirect
(
"/ac/users/CADCtest?idType=HTTP"
);
expectLastCall
().
once
();
LocalAuthority
localAuthority
=
new
LocalAuthority
();
URI
umsServiceURI
=
localAuthority
.
getServiceURI
(
Standards
.
UMS_WHOAMI_01
.
toString
());
URI
umsServiceURI
=
URI
.
create
(
"ivo://example.org/ums"
);
// expect(mockRegistry.getServiceURL(URI.create(umsServiceURI.toString() + "#users"),
// "http", "/%s?idType=HTTP")).
...
...
cadc-access-control-server/src/test/java/ca/nrc/cadc/ac/server/web/groups/AddGroupMemberActionTest.java
View file @
8c7b1018
...
...
@@ -85,8 +85,6 @@ import ca.nrc.cadc.ac.Group;
import
ca.nrc.cadc.ac.GroupAlreadyExistsException
;
import
ca.nrc.cadc.ac.GroupURI
;
import
ca.nrc.cadc.ac.server.GroupPersistence
;
import
ca.nrc.cadc.reg.Standards
;
import
ca.nrc.cadc.reg.client.LocalAuthority
;
import
ca.nrc.cadc.util.Log4jInit
;
/**
...
...
@@ -108,8 +106,7 @@ public class AddGroupMemberActionTest
{
try
{
LocalAuthority
localAuthority
=
new
LocalAuthority
();
URI
gmsServiceURI
=
localAuthority
.
getServiceURI
(
Standards
.
GMS_GROUPS_01
.
toString
());
URI
gmsServiceURI
=
URI
.
create
(
"ivo://example.org/gms"
);
Group
group
=
new
Group
(
new
GroupURI
(
gmsServiceURI
+
"?group"
));
Group
member
=
new
Group
(
new
GroupURI
(
gmsServiceURI
+
"?member"
));
...
...
@@ -120,7 +117,14 @@ public class AddGroupMemberActionTest
//expect(groupPersistence.getGroup("member")).andReturn(member);
replay
(
groupPersistence
);
AddGroupMemberAction
action
=
new
AddGroupMemberAction
(
"group"
,
"member"
);
AddGroupMemberAction
action
=
new
AddGroupMemberAction
(
"group"
,
"member"
)
{
@Override
public
URI
getServiceURI
(
URI
standard
)
{
return
URI
.
create
(
"ivo://example.org/gms"
);
}
};
action
.
groupPersistence
=
groupPersistence
;
try
...
...
@@ -142,8 +146,7 @@ public class AddGroupMemberActionTest
{
try
{
LocalAuthority
localAuthority
=
new
LocalAuthority
();
URI
gmsServiceURI
=
localAuthority
.
getServiceURI
(
Standards
.
GMS_GROUPS_01
.
toString
());
URI
gmsServiceURI
=
URI
.
create
(
"ivo://example.org/gms"
);
Group
group
=
new
Group
(
new
GroupURI
(
gmsServiceURI
+
"?group"
));
Group
member
=
new
Group
(
new
GroupURI
(
gmsServiceURI
+
"?member"
));
...
...
@@ -160,7 +163,14 @@ public class AddGroupMemberActionTest
replay
(
groupPersistence
);
AddGroupMemberAction
action
=
new
AddGroupMemberAction
(
"group"
,
"member"
);
AddGroupMemberAction
action
=
new
AddGroupMemberAction
(
"group"
,
"member"
)
{
@Override
public
URI
getServiceURI
(
URI
standard
)
{
return
URI
.
create
(
"ivo://example.org/gms"
);
}
};
action
.
groupPersistence
=
groupPersistence
;
GroupLogInfo
logInfo
=
createMock
(
GroupLogInfo
.
class
);
...
...
cadc-access-control-server/src/test/java/ca/nrc/cadc/ac/server/web/groups/RemoveGroupMemberActionTest.java
View file @
8c7b1018
...
...
@@ -83,8 +83,6 @@ import ca.nrc.cadc.ac.Group;
import
ca.nrc.cadc.ac.GroupNotFoundException
;
import
ca.nrc.cadc.ac.GroupURI
;
import
ca.nrc.cadc.ac.server.GroupPersistence
;
import
ca.nrc.cadc.reg.Standards
;
import
ca.nrc.cadc.reg.client.LocalAuthority
;
import
ca.nrc.cadc.util.Log4jInit
;
/**
...
...
@@ -136,9 +134,7 @@ public class RemoveGroupMemberActionTest
{
try
{
LocalAuthority
localAuthority
=
new
LocalAuthority
();
URI
gmsServiceURI
=
localAuthority
.
getServiceURI
(
Standards
.
GMS_GROUPS_01
.
toString
());
URI
gmsServiceURI
=
URI
.
create
(
"ivo://example.org/gms"
);
Group
member
=
new
Group
(
new
GroupURI
(
gmsServiceURI
.
toString
()
+
"?member"
));
Group
group
=
new
Group
(
new
GroupURI
(
gmsServiceURI
.
toString
()
+
"?group"
));
group
.
getGroupMembers
().
add
(
member
);
...
...
@@ -153,7 +149,14 @@ public class RemoveGroupMemberActionTest
EasyMock
.
expectLastCall
();
EasyMock
.
replay
(
groupPersistence
);
RemoveGroupMemberAction
action
=
new
RemoveGroupMemberAction
(
"group"
,
"member"
);
RemoveGroupMemberAction
action
=
new
RemoveGroupMemberAction
(
"group"
,
"member"
)
{
@Override
public
URI
getServiceURI
(
URI
standard
)
{
return
URI
.
create
(
"ivo://example.org/gms"
);
}
};
action
.
groupPersistence
=
groupPersistence
;
GroupLogInfo
logInfo
=
createMock
(
GroupLogInfo
.
class
);
...
...
cadc-access-control-server/src/test/java/ca/nrc/cadc/ac/server/web/groups/RemoveUserMemberActionTest.java
View file @
8c7b1018
...
...
@@ -94,8 +94,6 @@ import ca.nrc.cadc.ac.server.UserPersistence;
import
ca.nrc.cadc.auth.AuthenticationUtil
;
import
ca.nrc.cadc.auth.HttpPrincipal
;
import
ca.nrc.cadc.auth.IdentityType
;
import
ca.nrc.cadc.reg.Standards
;
import
ca.nrc.cadc.reg.client.LocalAuthority
;
import
ca.nrc.cadc.util.Log4jInit
;
import
ca.nrc.cadc.util.ObjectUtil
;
import
ca.nrc.cadc.util.PropertiesReader
;
...
...
@@ -128,8 +126,8 @@ public class RemoveUserMemberActionTest
try
{
User
user
=
new
User
();
LocalAuthority
localAuthority
=
new
LocalAuthority
();
URI
umsServiceURI
=
localAuthority
.
getServiceURI
(
Standards
.
UMS_REQS_01
.
toString
()
);
URI
umsServiceURI
=
URI
.
create
(
"ivo://example.org/ums"
);
InternalID
internalID
=
new
InternalID
(
new
URI
(
umsServiceURI
.
toASCIIString
()
+
"?"
+
UUID
.
randomUUID
()));
ObjectUtil
.
setField
(
user
,
internalID
,
"id"
);
...
...
@@ -182,8 +180,7 @@ public class RemoveUserMemberActionTest
try
{
User
user
=
new
User
();
LocalAuthority
localAuthority
=
new
LocalAuthority
();
URI
umsServiceURI
=
localAuthority
.
getServiceURI
(
Standards
.
UMS_REQS_01
.
toString
());
URI
umsServiceURI
=
URI
.
create
(
"ivo://example.org/ums"
);
InternalID
internalID
=
new
InternalID
(
new
URI
(
umsServiceURI
.
toString
()
+
"?"
+
UUID
.
randomUUID
()));
ObjectUtil
.
setField
(
user
,
internalID
,
"id"
);
...
...
@@ -213,6 +210,11 @@ public class RemoveUserMemberActionTest
{
return
mockUserPersistence
;
}
@Override
public
URI
getServiceURI
(
URI
standard
)
{
return
URI
.
create
(
"ivo://example.org/gms"
);
}
};
action
.
setGroupPersistence
(
mockGroupPersistence
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment