Skip to content
GitLab
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
110a1a5b
Commit
110a1a5b
authored
Mar 29, 2016
by
Jeff Burke
Browse files
s1890: unit test fixes
parent
6b3dc505
Changes
2
Hide whitespace changes
Inline
Side-by-side
cadcAccessControl-Server/test/src/ca/nrc/cadc/ac/server/web/groups/RemoveUserMemberActionTest.java
View file @
110a1a5b
...
...
@@ -71,11 +71,16 @@ package ca.nrc.cadc.ac.server.web.groups;
import
static
org
.
easymock
.
EasyMock
.
createMock
;
import
static
org
.
junit
.
Assert
.
fail
;
import
java.net.URI
;
import
java.security.Principal
;
import
java.util.UUID
;
import
javax.security.auth.x500.X500Principal
;
import
ca.nrc.cadc.ac.AC
;
import
ca.nrc.cadc.ac.InternalID
;
import
ca.nrc.cadc.auth.HttpPrincipal
;
import
ca.nrc.cadc.util.ObjectUtil
;
import
org.apache.log4j.Level
;
import
org.apache.log4j.Logger
;
import
org.easymock.EasyMock
;
...
...
@@ -111,11 +116,14 @@ public class RemoveUserMemberActionTest
{
try
{
User
user
=
new
User
();
InternalID
internalID
=
new
InternalID
(
new
URI
(
AC
.
USER_URI
+
"?"
+
UUID
.
randomUUID
()));
ObjectUtil
.
setField
(
user
,
internalID
,
"id"
);
String
userID
=
"cn=foo,c=ca"
;
String
userIDType
=
IdentityType
.
X500
.
getValue
();
Principal
userPrincipal
=
AuthenticationUtil
.
createPrincipal
(
userID
,
userIDType
);
User
user
=
new
User
();
user
.
getIdentities
().
add
(
userPrincipal
);
Principal
x500Principal
=
AuthenticationUtil
.
createPrincipal
(
userID
,
userIDType
);
user
.
getIdentities
().
add
(
x500Principal
);
Group
group
=
new
Group
(
"group"
);
User
member
=
new
User
();
...
...
@@ -126,7 +134,7 @@ public class RemoveUserMemberActionTest
EasyMock
.
expect
(
mockGroupPersistence
.
getGroup
(
"group"
)).
andReturn
(
group
);
final
UserPersistence
mockUserPersistence
=
EasyMock
.
createMock
(
UserPersistence
.
class
);
EasyMock
.
expect
(
mockUserPersistence
.
getUser
(
user
Principal
)).
andReturn
(
user
);
EasyMock
.
expect
(
mockUserPersistence
.
get
Augmented
User
(
x500
Principal
)).
andReturn
(
user
);
EasyMock
.
replay
(
mockGroupPersistence
,
mockUserPersistence
);
...
...
@@ -160,10 +168,13 @@ public class RemoveUserMemberActionTest
{
try
{
User
user
=
new
User
();
InternalID
internalID
=
new
InternalID
(
new
URI
(
AC
.
USER_URI
+
"?"
+
UUID
.
randomUUID
()));
ObjectUtil
.
setField
(
user
,
internalID
,
"id"
);
String
userID
=
"cn=foo,c=ca"
;
String
userIDType
=
IdentityType
.
X500
.
getValue
();
Principal
userPrincipal
=
AuthenticationUtil
.
createPrincipal
(
userID
,
userIDType
);
User
user
=
new
User
();
user
.
getIdentities
().
add
(
new
X500Principal
(
userID
));
user
.
getIdentities
().
add
(
new
HttpPrincipal
(
"foo"
));
...
...
@@ -176,7 +187,7 @@ public class RemoveUserMemberActionTest
EasyMock
.
expectLastCall
();
final
UserPersistence
mockUserPersistence
=
EasyMock
.
createMock
(
UserPersistence
.
class
);
EasyMock
.
expect
(
mockUserPersistence
.
getUser
(
userPrincipal
)).
andReturn
(
user
);
EasyMock
.
expect
(
mockUserPersistence
.
get
Augmented
User
(
userPrincipal
)).
andReturn
(
user
);
EasyMock
.
replay
(
mockGroupPersistence
,
mockUserPersistence
);
...
...
cadcAccessControl/test/src/ca/nrc/cadc/ac/client/UserClientTest.java
View file @
110a1a5b
...
...
@@ -108,16 +108,32 @@ public class UserClientTest
try
{
new
UserClient
(
null
);
Assert
.
fail
(
"Null
bas
e UR
L
should throw an illegalArgumentException."
);
Assert
.
fail
(
"Null
servic
e UR
I
should throw an illegalArgumentException."
);
}
catch
(
IllegalArgumentException
iae
)
{
Assert
.
assertTrue
(
iae
.
getMessage
().
contains
(
"
invalid serviceURI
"
));
Assert
.
assertTrue
(
iae
.
getMessage
().
contains
(
"
cannot be null
"
));
}
catch
(
Throwable
t
)
{
Assert
.
fail
(
"Unexpected exception: "
+
t
.
getMessage
());
}
// case 2: serviceURI with a fragment
try
{
URI
uri
=
new
URI
(
"http://foo.com/bar?test#fragment"
);
new
UserClient
(
uri
);
Assert
.
fail
(
"Service URI containing a fragment should throw an illegalArgumentException."
);
}
catch
(
IllegalArgumentException
iae
)
{
Assert
.
assertTrue
(
iae
.
getMessage
().
contains
(
"fragment not allowed"
));
}
catch
(
Throwable
t
)
{
Assert
.
fail
(
"Unexpected exception: "
+
t
.
getMessage
());
}
}
@Test
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment