use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ExternalIdIT method deleteExternalIds_Conflict.
@Test
public void deleteExternalIds_Conflict() throws Exception {
List<String> toDelete = new ArrayList<>();
String externalIdStr = "username:" + user.username;
toDelete.add(externalIdStr);
RestResponse response = userRestSession.post("/accounts/self/external.ids:delete", toDelete);
response.assertConflict();
assertThat(response.getEntityContent()).isEqualTo(String.format("External id %s cannot be deleted", externalIdStr));
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ExternalIdIT method deleteExternalIds.
@Test
public void deleteExternalIds() throws Exception {
setApiUser(user);
List<AccountExternalIdInfo> externalIds = gApi.accounts().self().getExternalIds();
List<String> toDelete = new ArrayList<>();
List<AccountExternalIdInfo> expectedIds = new ArrayList<>();
for (AccountExternalIdInfo id : externalIds) {
if (id.canDelete != null && id.canDelete) {
toDelete.add(id.identity);
continue;
}
expectedIds.add(id);
}
assertThat(toDelete).hasSize(1);
RestResponse response = userRestSession.post("/accounts/self/external.ids:delete", toDelete);
response.assertNoContent();
List<AccountExternalIdInfo> results = gApi.accounts().self().getExternalIds();
// The external ID in WebSession will not be set for tests, resulting that
// "mailto:user@example.com" can be deleted while "username:user" can't.
assertThat(results).hasSize(1);
assertThat(results).containsExactlyElementsIn(expectedIds);
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class EmailIT method deleteEmail.
@Test
public void deleteEmail() throws Exception {
String email = "foo.baz@example.com";
assertThat(getEmails()).doesNotContain(email);
createEmail(email);
assertThat(getEmails()).contains(email);
RestResponse r = adminRestSession.delete("/accounts/self/emails/" + email);
r.assertNoContent();
assertThat(getEmails()).doesNotContain(email);
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class EmailIT method deleteUrlEncodedEmail.
@Test
public void deleteUrlEncodedEmail() throws Exception {
String email = "foo.baz2@example.com";
assertThat(getEmails()).doesNotContain(email);
createEmail(email);
assertThat(getEmails()).contains(email);
RestResponse r = adminRestSession.delete("/accounts/self/emails/" + email.replace("@", "%40"));
r.assertNoContent();
assertThat(getEmails()).doesNotContain(email);
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ExternalIdIT method deleteExternalIdsOfOtherUserWithAccessDatabase.
@Test
public void deleteExternalIdsOfOtherUserWithAccessDatabase() throws Exception {
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
List<AccountExternalIdInfo> externalIds = gApi.accounts().self().getExternalIds();
List<String> toDelete = new ArrayList<>();
List<AccountExternalIdInfo> expectedIds = new ArrayList<>();
for (AccountExternalIdInfo id : externalIds) {
if (id.canDelete != null && id.canDelete) {
toDelete.add(id.identity);
continue;
}
expectedIds.add(id);
}
assertThat(toDelete).hasSize(1);
setApiUser(user);
RestResponse response = userRestSession.post("/accounts/" + admin.id + "/external.ids:delete", toDelete);
response.assertNoContent();
List<AccountExternalIdInfo> results = gApi.accounts().id(admin.id.get()).getExternalIds();
// The external ID in WebSession will not be set for tests, resulting that
// "mailto:user@example.com" can be deleted while "username:user" can't.
assertThat(results).hasSize(1);
assertThat(results).containsExactlyElementsIn(expectedIds);
}
Aggregations