use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.
the class UserFinderTest method testLastLogin.
@Test
public void testLastLogin() throws Throwable {
final SUser user10 = createUser("user10");
final SUser user20 = createUser("user20");
final SUser user30 = createUser("user30");
final MockTimeService time = new MockTimeService(Dates.now().getTime());
myServer.setTimeService(time);
user10.setLastLoginTimestamp(time.getNow());
// 10 minutes
time.jumpTo(600);
user20.setLastLoginTimestamp(time.getNow());
// another 10
time.jumpTo(600);
check(null, user10, user20, user30);
check("lastLogin:-30m", user10, user20);
check("lastLogin:-15m", user20);
check("lastLogin:-15m,username:user20", user20);
check("lastLogin:-5m");
}
use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.
the class UserFinderTest method testSecurity.
@Test
public void testSecurity() throws Throwable {
myFixture.getServerSettings().setPerProjectPermissionsEnabled(true);
final SUser user1 = createUser("user1");
final SUser user2 = createUser("user2");
final SecurityContextImpl securityContext = myFixture.getSecurityContext();
securityContext.runAs(user1, new SecurityContextEx.RunAsAction() {
@Override
public void run() throws Throwable {
checkExceptionOnItemsSearch(AuthorizationFailedException.class, null);
// this works as this is single item search actually
check("user2", user2);
checkExceptionOnItemsSearch(AuthorizationFailedException.class, "group:ALL_USERS_GROUP");
check("user1", user1);
checkException(AuthorizationFailedException.class, new Runnable() {
@Override
public void run() {
((UserFinder) getFinder()).getItem("user2", true);
}
}, null);
}
});
}
use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.
the class UserFinderTest method testGroupLocator.
@Test
public void testGroupLocator() throws Throwable {
SUserGroup group1 = myFixture.createUserGroup("key1", "name1", "description");
final SUser user1 = createUser("user1");
final SUser user2 = createUser("user2");
final SUser user25 = createUser("user25");
group1.addUser(user1);
group1.addUser(user2);
group1.addUser(user25);
SUserGroup group2 = myFixture.createUserGroup("key2", "name2", "description");
final SUser user3 = createUser("user3");
group2.addUser(user3);
group2.addUser(user25);
check(null, user1, user2, user25, user3);
check("group:(key:" + group1.getKey() + ")", user1, user2, user25);
check("group:(key:" + group2.getKey() + ")", user3, user25);
check("group:(key:" + getUserGroupManager().getAllUsersGroup().getKey() + ")", user1, user2, user25, user3);
check("group:(key:" + group1.getKey() + "),username:user1", user1);
checkExceptionOnItemSearch(NotFoundException.class, "group:(key:XXX)");
checkExceptionOnItemsSearch(NotFoundException.class, "group:(key:XXX)");
check("group:(key:" + group1.getKey() + "),group:(key:" + group2.getKey() + ")", user25);
}
use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.
the class UserFinderTest method testSingleLocator.
@Test
public void testSingleLocator() throws Throwable {
final SUser user1 = createUser("user1");
{
SUser result = myUserFinder.getItem("user1");
assertNotNull(result);
assertEquals(user1.getId(), result.getId());
}
BaseFinderTest.checkException(NotFoundException.class, new Runnable() {
public void run() {
myUserFinder.getItem("user1" + "2");
}
}, null);
}
use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.
the class UserFinderTest method testLogicOps.
@Test
public void testLogicOps() throws Throwable {
SUserGroup group1 = myFixture.createUserGroup("key1", "name1", "description");
final SUser user1 = createUser("user1");
final SUser user2 = createUser("user2");
final SUser user3 = createUser("user3");
final SUser user4 = createUser("user4");
group1.addUser(user1);
group1.addUser(user2);
SUserGroup group2 = myFixture.createUserGroup("key2", "name2", "description");
group2.addUser(user3);
group2.addUser(user2);
check(null, user1, user2, user3, user4);
check("group:(key:" + group1.getKey() + ")", user1, user2);
// todo: should actually return sorted
check("group:(key:" + group2.getKey() + ")", user3, user2);
check("group:(key:" + group1.getKey() + "),group:(key:" + group2.getKey() + ")", user2);
check("group:(key:" + group1.getKey() + "),and:(group:(key:" + group2.getKey() + "))", user2);
check("and:(group:(key:" + group1.getKey() + "),group:(key:" + group2.getKey() + "))", user2);
check("or:(group:(key:" + group1.getKey() + "),group:(key:" + group2.getKey() + "))", user1, user2, user3);
check("not:(group:(key:" + group1.getKey() + "))", user3, user4);
check("not:(or:(group:(key:" + group1.getKey() + "),group:(key:" + group2.getKey() + ")))", user4);
// Only single 'and' dimension is supported in locator
checkExceptionOnItemsSearch(LocatorProcessException.class, "and:(group:(key:" + group1.getKey() + ")),and:group:(key:" + group2.getKey() + "))");
}
Aggregations