Search in sources :

Example 1 with AccountDetailInfo

use of com.google.gerrit.extensions.common.AccountDetailInfo in project gerrit by GerritCodeReview.

the class GetAccountDetailIT method getDetailForServiceUser.

@Test
public void getDetailForServiceUser() throws Exception {
    Account.Id serviceUser = accountOperations.newAccount().create();
    groupOperations.group(groupCache.get(AccountGroup.nameKey(ServiceUserClassifier.SERVICE_USERS)).get().getGroupUUID()).forUpdate().addMember(serviceUser).update();
    RestResponse r = adminRestSession.get("/accounts/" + serviceUser.get() + "/detail/");
    AccountDetailInfo info = newGson().fromJson(r.getReader(), AccountDetailInfo.class);
    assertThat(info.tags).containsExactly(AccountInfo.Tags.SERVICE_USER);
}
Also used : Account(com.google.gerrit.entities.Account) AccountDetailInfo(com.google.gerrit.extensions.common.AccountDetailInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with AccountDetailInfo

use of com.google.gerrit.extensions.common.AccountDetailInfo in project gerrit by GerritCodeReview.

the class GetDetail method apply.

@Override
public Response<AccountDetailInfo> apply(AccountResource rsrc) throws PermissionBackendException {
    Account a = rsrc.getUser().getAccount();
    AccountDetailInfo info = new AccountDetailInfo(a.id().get());
    info.setRegisteredOn(a.registeredOn());
    info.inactive = !a.isActive() ? true : null;
    directory.fillAccountInfo(Collections.singleton(info), EnumSet.allOf(FillOptions.class));
    return Response.ok(info);
}
Also used : Account(com.google.gerrit.entities.Account) AccountDetailInfo(com.google.gerrit.extensions.common.AccountDetailInfo) FillOptions(com.google.gerrit.server.account.AccountDirectory.FillOptions)

Example 3 with AccountDetailInfo

use of com.google.gerrit.extensions.common.AccountDetailInfo in project gerrit by GerritCodeReview.

the class AccountIT method getOwnDetail.

@Test
public void getOwnDetail() throws Exception {
    String email = "preferred@example.com";
    String name = "Foo";
    String username = name("foo");
    TestAccount foo = accountCreator.create(username, email, name, null);
    String secondaryEmail = "secondary@example.com";
    EmailInput input = newEmailInput(secondaryEmail);
    gApi.accounts().id(foo.id().get()).addEmail(input);
    String status = "OOO";
    gApi.accounts().id(foo.id().get()).setStatus(status);
    requestScopeOperations.setApiUser(foo.id());
    AccountDetailInfo detail = gApi.accounts().id(foo.id().get()).detail();
    assertThat(detail._accountId).isEqualTo(foo.id().get());
    assertThat(detail.name).isEqualTo(name);
    assertThat(detail.username).isEqualTo(username);
    assertThat(detail.email).isEqualTo(email);
    assertThat(detail.secondaryEmails).containsExactly(secondaryEmail);
    assertThat(detail.status).isEqualTo(status);
    assertThat(detail.registeredOn.getTime()).isEqualTo(getAccount(foo.id()).registeredOn().toEpochMilli());
    assertThat(detail.inactive).isNull();
    assertThat(detail._moreAccounts).isNull();
}
Also used : AccountDetailInfo(com.google.gerrit.extensions.common.AccountDetailInfo) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) TestAccount(com.google.gerrit.acceptance.TestAccount) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 4 with AccountDetailInfo

use of com.google.gerrit.extensions.common.AccountDetailInfo in project gerrit by GerritCodeReview.

the class AccountIT method detailOfOtherAccountIncludeSecondaryEmailsWithModifyAccount.

@Test
public void detailOfOtherAccountIncludeSecondaryEmailsWithModifyAccount() throws Exception {
    String email = "preferred@example.com";
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
    String secondaryEmail = "secondary@example.com";
    EmailInput input = newEmailInput(secondaryEmail);
    gApi.accounts().id(foo.id().get()).addEmail(input);
    AccountDetailInfo detail = gApi.accounts().id(foo.id().get()).detail();
    assertThat(detail.secondaryEmails).containsExactly(secondaryEmail);
}
Also used : AccountDetailInfo(com.google.gerrit.extensions.common.AccountDetailInfo) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) TestAccount(com.google.gerrit.acceptance.TestAccount) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 5 with AccountDetailInfo

use of com.google.gerrit.extensions.common.AccountDetailInfo in project gerrit by GerritCodeReview.

the class AccountIT method detailOfOtherAccountDoesntIncludeSecondaryEmailsWithoutModifyAccount.

@Test
public void detailOfOtherAccountDoesntIncludeSecondaryEmailsWithoutModifyAccount() throws Exception {
    String email = "preferred@example.com";
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
    String secondaryEmail = "secondary@example.com";
    EmailInput input = newEmailInput(secondaryEmail);
    gApi.accounts().id(foo.id().get()).addEmail(input);
    requestScopeOperations.setApiUser(user.id());
    AccountDetailInfo detail = gApi.accounts().id(foo.id().get()).detail();
    assertThat(detail.secondaryEmails).isNull();
}
Also used : AccountDetailInfo(com.google.gerrit.extensions.common.AccountDetailInfo) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) TestAccount(com.google.gerrit.acceptance.TestAccount) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

AccountDetailInfo (com.google.gerrit.extensions.common.AccountDetailInfo)8 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)7 Test (org.junit.Test)7 RestResponse (com.google.gerrit.acceptance.RestResponse)4 Account (com.google.gerrit.entities.Account)4 TestAccount (com.google.gerrit.acceptance.TestAccount)3 EmailInput (com.google.gerrit.extensions.api.accounts.EmailInput)3 PublicKeyStore.keyToString (com.google.gerrit.gpg.PublicKeyStore.keyToString)3 FillOptions (com.google.gerrit.server.account.AccountDirectory.FillOptions)1