use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class SearchMyOrganizationsActionTest method verify_response_example.
@Test
public void verify_response_example() {
OrganizationDto organization1 = dbTester.organizations().insertForKey("my-org");
OrganizationDto organization2 = dbTester.organizations().insertForKey("foo-corp");
UserDto user = dbTester.users().insertUser();
dbTester.users().insertPermissionOnUser(organization1, user, SYSTEM_ADMIN);
dbTester.users().insertPermissionOnUser(organization2, user, SYSTEM_ADMIN);
userSessionRule.logIn(user);
TestResponse response = underTest.newRequest().execute();
assertJson(response.getInput()).isSimilarTo(underTest.getDef().responseExampleAsString());
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class SearchMyOrganizationsActionTest method returns_empty_array_when_user_is_logged_in_and_has_no_permission_on_anything.
@Test
public void returns_empty_array_when_user_is_logged_in_and_has_no_permission_on_anything() {
userSessionRule.logIn();
TestResponse response = underTest.newRequest().execute();
assertJson(response.getInput()).isSimilarTo(NO_ORGANIZATIONS_RESPONSE);
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class SearchMyOrganizationsActionTest method returns_empty_response_when_user_is_not_logged_in.
@Test
public void returns_empty_response_when_user_is_not_logged_in() {
TestResponse response = underTest.newRequest().execute();
assertThat(response.getStatus()).isEqualTo(204);
assertThat(response.getInput()).isEmpty();
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class CreateTemplateActionTest method create_full_permission_template.
@Test
public void create_full_permission_template() throws Exception {
loginAsAdmin(db.getDefaultOrganization());
TestResponse result = newRequest("Finance", "Permissions for financially related projects", ".*\\.finance\\..*");
assertJson(result.getInput()).ignoreFields("id").isSimilarTo(getClass().getResource("create_template-example.json"));
PermissionTemplateDto finance = selectTemplateInDefaultOrganization("Finance");
assertThat(finance.getName()).isEqualTo("Finance");
assertThat(finance.getDescription()).isEqualTo("Permissions for financially related projects");
assertThat(finance.getKeyPattern()).isEqualTo(".*\\.finance\\..*");
assertThat(finance.getUuid()).isNotEmpty();
assertThat(finance.getCreatedAt().getTime()).isEqualTo(NOW);
assertThat(finance.getUpdatedAt().getTime()).isEqualTo(NOW);
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class IndexActionTest method allow_client_to_cache_messages.
@Test
public void allow_client_to_cache_messages() throws Exception {
Date now = new Date();
Date aBitLater = new Date(now.getTime() + 1000);
when(server.getStartedAt()).thenReturn(now);
TestResponse result = call(null, DateUtils.formatDateTime(aBitLater));
verifyZeroInteractions(i18n);
verify(server).getStartedAt();
assertThat(result.getStatus()).isEqualTo(HttpURLConnection.HTTP_NOT_MODIFIED);
}
Aggregations