Search in sources :

Example 1 with LicensingData

use of jetbrains.buildServer.server.rest.model.server.LicensingData in project teamcity-rest by JetBrains.

the class ServerRequestTest method test_default_fields_in_licensing_data.

@Test
public void test_default_fields_in_licensing_data() throws Throwable {
    final SUser user = createUser("user");
    user.addRole(RoleScope.globalScope(), getSysAdminRole());
    LicensingData data = myRequest.getLicensingData("");
    assertNotNull(data.maxAgents);
    assertNotNull(data.getAgentsLeft());
    assertNotNull(data.serverLicenseType);
    assertNotNull(data.serverEffectiveReleaseDate);
    assertNotNull(data.licenseKeys);
}
Also used : LicensingData(jetbrains.buildServer.server.rest.model.server.LicensingData) SUser(jetbrains.buildServer.users.SUser) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test)

Example 2 with LicensingData

use of jetbrains.buildServer.server.rest.model.server.LicensingData in project teamcity-rest by JetBrains.

the class ServerRequestTest method test_user_needs_view_agent_details_permission_to_access_avaliable_agents.

@Test(description = "TW-68673")
public void test_user_needs_view_agent_details_permission_to_access_avaliable_agents() throws Throwable {
    MockAuthorityHolder mockUser = new MockAuthorityHolder();
    mockUser.globalPerms = new Permissions(Permission.VIEW_AGENT_DETAILS);
    myFixture.getSecurityContext().runAs(mockUser, () -> {
        LicensingData data = myRequest.getLicensingData("maxAgents,serverLicenseType,agentsLeft");
        assertNull(data.maxAgents);
        assertNull(data.serverLicenseType);
        assertNotNull(data.getAgentsLeft());
    });
}
Also used : LicensingData(jetbrains.buildServer.server.rest.model.server.LicensingData) Permissions(jetbrains.buildServer.serverSide.auth.Permissions) MockAuthorityHolder(jetbrains.buildServer.serverSide.impl.MockAuthorityHolder) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test)

Example 3 with LicensingData

use of jetbrains.buildServer.server.rest.model.server.LicensingData in project teamcity-rest by JetBrains.

the class ServerRequestTest method test_user_with_enough_permissions_should_get_licensing_data.

@Test
public void test_user_with_enough_permissions_should_get_licensing_data() throws Throwable {
    final SUser user = createUser("user");
    user.addRole(RoleScope.globalScope(), getSysAdminRole());
    LicensingData data = myRequest.getLicensingData("licenseUseExceeded,maxAgents,unlimitedAgents,agentsLeft,maxBuildTypes,unlimitedBuildTypes,buildTypesLeft,serverLicenseType");
    assertNotNull(data.licenseUseExceeded);
    assertNotNull(data.maxAgents);
    assertNotNull(data.unlimitedAgents);
    assertNotNull(data.getAgentsLeft());
}
Also used : LicensingData(jetbrains.buildServer.server.rest.model.server.LicensingData) SUser(jetbrains.buildServer.users.SUser) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test)

Example 4 with LicensingData

use of jetbrains.buildServer.server.rest.model.server.LicensingData in project teamcity-rest by JetBrains.

the class ServerRequestTest method test_user_needs_manage_server_licenses_permission_to_access_licensing_data.

@Test
public void test_user_needs_manage_server_licenses_permission_to_access_licensing_data() throws Throwable {
    MockAuthorityHolder mockUser = new MockAuthorityHolder();
    myFixture.getSecurityContext().runAs(mockUser, () -> {
        LicensingData data = myRequest.getLicensingData("maxAgents,serverLicenseType,agentsLeft");
        assertNull(data.maxAgents);
        assertNull(data.serverLicenseType);
        assertNull(data.getAgentsLeft());
    });
    mockUser.globalPerms = new Permissions(Permission.MANAGE_SERVER_LICENSES);
    myFixture.getSecurityContext().runAs(mockUser, () -> {
        LicensingData data = myRequest.getLicensingData("maxAgents,serverLicenseType,agentsLeft");
        assertNotNull(data.maxAgents);
        assertNotNull(data.serverLicenseType);
        assertNotNull(data.getAgentsLeft());
    });
}
Also used : LicensingData(jetbrains.buildServer.server.rest.model.server.LicensingData) Permissions(jetbrains.buildServer.serverSide.auth.Permissions) MockAuthorityHolder(jetbrains.buildServer.serverSide.impl.MockAuthorityHolder) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test)

Aggregations

BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)4 LicensingData (jetbrains.buildServer.server.rest.model.server.LicensingData)4 Test (org.testng.annotations.Test)4 Permissions (jetbrains.buildServer.serverSide.auth.Permissions)2 MockAuthorityHolder (jetbrains.buildServer.serverSide.impl.MockAuthorityHolder)2 SUser (jetbrains.buildServer.users.SUser)2