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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OATS-CADC
ac
Commits
166e816e
Commit
166e816e
authored
10 years ago
by
Jeff Burke
Browse files
Options
Downloads
Patches
Plain Diff
s1666: updated GroupDAO unit tests
parent
c4bf1457
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
projects/cadcAccessControl-Server/test/src/ca/nrc/cadc/ac/server/ldap/LdapGroupDAOTest.java
+52
-54
52 additions, 54 deletions
...test/src/ca/nrc/cadc/ac/server/ldap/LdapGroupDAOTest.java
with
52 additions
and
54 deletions
projects/cadcAccessControl-Server/test/src/ca/nrc/cadc/ac/server/ldap/LdapGroupDAOTest.java
+
52
−
54
View file @
166e816e
...
@@ -139,7 +139,7 @@ public class LdapGroupDAOTest
...
@@ -139,7 +139,7 @@ public class LdapGroupDAOTest
return
"CadcDaoTestGroup-"
+
System
.
currentTimeMillis
();
return
"CadcDaoTestGroup-"
+
System
.
currentTimeMillis
();
}
}
//
@Test
@Test
public
void
testOneGroup
()
throws
Exception
public
void
testOneGroup
()
throws
Exception
{
{
// do everything as owner
// do everything as owner
...
@@ -222,7 +222,7 @@ public class LdapGroupDAOTest
...
@@ -222,7 +222,7 @@ public class LdapGroupDAOTest
});
});
}
}
//
@Test
@Test
public
void
testSearchOwnerGroups
()
throws
Exception
public
void
testSearchOwnerGroups
()
throws
Exception
{
{
Subject
.
doAs
(
daoTestUser1Subject
,
new
PrivilegedExceptionAction
<
Object
>()
Subject
.
doAs
(
daoTestUser1Subject
,
new
PrivilegedExceptionAction
<
Object
>()
...
@@ -270,7 +270,7 @@ public class LdapGroupDAOTest
...
@@ -270,7 +270,7 @@ public class LdapGroupDAOTest
});
});
}
}
//
@Test
@Test
public
void
testSearchMemberGroups
()
throws
Exception
public
void
testSearchMemberGroups
()
throws
Exception
{
{
final
String
groupID
=
getGroupID
();
final
String
groupID
=
getGroupID
();
...
@@ -371,7 +371,7 @@ public class LdapGroupDAOTest
...
@@ -371,7 +371,7 @@ public class LdapGroupDAOTest
});
});
}
}
//
@Test
@Test
public
void
testSearchAdminGroups
()
throws
Exception
public
void
testSearchAdminGroups
()
throws
Exception
{
{
final
String
groupID
=
getGroupID
();
final
String
groupID
=
getGroupID
();
...
@@ -492,7 +492,7 @@ public class LdapGroupDAOTest
...
@@ -492,7 +492,7 @@ public class LdapGroupDAOTest
Group
testGroup2
=
new
Group
(
testGroup2ID
,
daoTestUser1
);
Group
testGroup2
=
new
Group
(
testGroup2ID
,
daoTestUser1
);
testGroup2
=
getGroupDAO
().
addGroup
(
testGroup2
);
testGroup2
=
getGroupDAO
().
addGroup
(
testGroup2
);
log
.
debug
(
"add group: "
+
testGroup2ID
);
log
.
debug
(
"add group: "
+
testGroup2ID
);
Thread
.
sleep
(
1000
);
// sleep to let memberof plugin do its work
//
Thread.sleep(1000); // sleep to let memberof plugin do its work
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
...
@@ -563,7 +563,7 @@ public class LdapGroupDAOTest
...
@@ -563,7 +563,7 @@ public class LdapGroupDAOTest
});
});
}
}
//
@Test
@Test
public
void
testAddGroupExceptions
()
throws
Exception
public
void
testAddGroupExceptions
()
throws
Exception
{
{
Subject
.
doAs
(
anonSubject
,
new
PrivilegedExceptionAction
<
Object
>()
Subject
.
doAs
(
anonSubject
,
new
PrivilegedExceptionAction
<
Object
>()
...
@@ -610,7 +610,7 @@ public class LdapGroupDAOTest
...
@@ -610,7 +610,7 @@ public class LdapGroupDAOTest
});
});
}
}
//
@Test
@Test
public
void
testGetGroupExceptions
()
throws
Exception
public
void
testGetGroupExceptions
()
throws
Exception
{
{
final
String
groupID
=
getGroupID
();
final
String
groupID
=
getGroupID
();
...
@@ -662,23 +662,24 @@ public class LdapGroupDAOTest
...
@@ -662,23 +662,24 @@ public class LdapGroupDAOTest
}
}
});
});
Subject
.
doAs
(
daoTestUser2Subject
,
new
PrivilegedExceptionAction
<
Object
>()
// All access ACI's will allow anonymous access
{
// Subject.doAs(daoTestUser2Subject, new PrivilegedExceptionAction<Object>()
public
Object
run
()
throws
Exception
// {
{
// public Object run() throws Exception
try
// {
{
// try
getGroupDAO
().
getGroup
(
groupID
);
// {
fail
(
"getGroup with anonymous access should throw "
+
// getGroupDAO().getGroup(groupID);
"AccessControlException"
);
// fail("getGroup with anonymous access should throw " +
}
// "AccessControlException");
catch
(
AccessControlException
ignore
)
{}
// }
return
null
;
// catch (AccessControlException ignore) {}
}
// return null;
});
// }
// });
}
}
//
@Test
@Test
public
void
testModifyGroupExceptions
()
throws
Exception
public
void
testModifyGroupExceptions
()
throws
Exception
{
{
final
String
groupID
=
getGroupID
();
final
String
groupID
=
getGroupID
();
...
@@ -725,7 +726,7 @@ public class LdapGroupDAOTest
...
@@ -725,7 +726,7 @@ public class LdapGroupDAOTest
});
});
}
}
//
@Test
@Test
public
void
testDeleteGroupExceptions
()
throws
Exception
public
void
testDeleteGroupExceptions
()
throws
Exception
{
{
final
String
groupID
=
getGroupID
();
final
String
groupID
=
getGroupID
();
...
@@ -772,7 +773,7 @@ public class LdapGroupDAOTest
...
@@ -772,7 +773,7 @@ public class LdapGroupDAOTest
});
});
}
}
//
@Test
@Test
public
void
testSearchGroupsExceptions
()
throws
Exception
public
void
testSearchGroupsExceptions
()
throws
Exception
{
{
final
String
groupID
=
getGroupID
();
final
String
groupID
=
getGroupID
();
...
@@ -820,6 +821,29 @@ public class LdapGroupDAOTest
...
@@ -820,6 +821,29 @@ public class LdapGroupDAOTest
}
}
});
});
//
// change the user
// Subject.doAs(daoTestUser2Subject, new PrivilegedExceptionAction<Object>()
// {
// public Object run() throws Exception
// {
// try
// {
// Group group = getGroupDAO().getGroup(groupID);
// assertTrue(group == null);
//
// fail("searchGroups with un-authorized user should throw " +
// "AccessControlException");
// }
// catch (AccessControlException ignore)
// {
//
// }
//
// return null;
// }
// });
Subject
.
doAs
(
daoTestUser1Subject
,
new
PrivilegedExceptionAction
<
Object
>()
Subject
.
doAs
(
daoTestUser1Subject
,
new
PrivilegedExceptionAction
<
Object
>()
{
{
public
Object
run
()
throws
Exception
public
Object
run
()
throws
Exception
...
@@ -828,32 +852,6 @@ public class LdapGroupDAOTest
...
@@ -828,32 +852,6 @@ public class LdapGroupDAOTest
return
null
;
return
null
;
}
}
});
});
// change the user
Subject
.
doAs
(
daoTestUser2Subject
,
new
PrivilegedExceptionAction
<
Object
>()
{
public
Object
run
()
throws
Exception
{
try
{
Group
group
=
getGroupDAO
().
getGroup
(
groupID
);
assertTrue
(
group
==
null
);
fail
(
"searchGroups with un-authorized user should throw "
+
"AccessControlException"
);
}
catch
(
AccessControlException
ignore
)
{
}
return
null
;
}
});
}
}
private
void
assertGroupsEqual
(
Group
gr1
,
Group
gr2
)
private
void
assertGroupsEqual
(
Group
gr1
,
Group
gr2
)
...
...
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