Skip to content

Commit 280ff92

Browse files
author
gdgate
authored
Merge pull request #1060 from gooddata/liry4
Add AuthenticationMode enum to Account Reviewed-by: Jiri Mikulasek <jiri.mikulasek@gooddata.com> https://github.com/jimirocks
2 parents 5c0a234 + 07e53e1 commit 280ff92

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

gooddata-java-model/src/main/java/com/gooddata/sdk/model/account/Account.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
package com.gooddata.sdk.model.account;
77

88
import com.fasterxml.jackson.annotation.*;
9-
import com.gooddata.sdk.model.util.UriHelper;
109
import com.gooddata.sdk.common.util.GoodDataToStringBuilder;
10+
import com.gooddata.sdk.model.util.UriHelper;
1111

1212
import java.util.List;
1313

@@ -205,4 +205,18 @@ public String toString() {
205205
*/
206206
public static class UpdateView {
207207
}
208+
209+
/**
210+
* Enumeration type representing GoodData authentication mode.
211+
*/
212+
public enum AuthenticationMode {
213+
/**
214+
* User can be authenticated using password
215+
*/
216+
PASSWORD,
217+
/**
218+
* User can be authenticated via SSO
219+
*/
220+
SSO
221+
}
208222
}

gooddata-java-model/src/test/java/com/gooddata/sdk/model/account/AccountTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import org.testng.annotations.Test;
99

10+
import static com.gooddata.sdk.model.account.Account.AuthenticationMode.SSO;
1011
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
1112
import static net.javacrumbs.jsonunit.core.util.ResourceUtils.resource;
1213
import static com.gooddata.sdk.common.util.ResourceUtils.readObjectFromResource;
@@ -37,14 +38,14 @@ public void testDeserialize() throws Exception {
3738
assertThat(account.getUri(), is("/gdc/account/profile/ID"));
3839
assertThat(account.getProjectsUri(), is("/gdc/account/profile/ID/projects"));
3940
assertThat(account.getIpWhitelist(), contains(IP));
40-
assertThat(account.getAuthenticationModes(), contains("SSO"));
41+
assertThat(account.getAuthenticationModes(), contains(SSO.toString()));
4142
}
4243

4344
@Test
4445
public void testSerialization() {
4546
final Account account = new Account(FIRST_NAME, LAST_NAME, null);
4647
account.setIpWhitelist(Collections.singletonList("1.2.3.4/32"));
47-
account.setAuthenticationModes(Collections.singletonList("SSO"));
48+
account.setAuthenticationModes(Collections.singletonList(SSO.toString()));
4849
assertThat(account, jsonEquals(resource("account/account-input.json")));
4950
}
5051

gooddata-java/src/test/java/com/gooddata/sdk/service/account/AccountServiceAT.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
import org.testng.annotations.AfterClass;
1212
import org.testng.annotations.Test;
1313

14-
import java.util.Collections;
1514
import java.util.UUID;
1615

16+
import static com.gooddata.sdk.model.account.Account.AuthenticationMode.PASSWORD;
17+
import static com.gooddata.sdk.model.account.Account.AuthenticationMode.SSO;
18+
import static java.util.Arrays.asList;
1719
import static org.hamcrest.MatcherAssert.assertThat;
18-
import static org.hamcrest.Matchers.is;
19-
import static org.hamcrest.Matchers.notNullValue;
20+
import static org.hamcrest.Matchers.*;
2021

2122
/**
2223
* Account acceptance tests.
@@ -39,13 +40,13 @@ public void login() throws Exception {
3940
@Test(groups = "isolated_domain")
4041
public void createAccount() {
4142
final Account newAccount = new Account(LOGIN, "w4yYxSQpAbaODA64", "FistName", "LastName");
42-
newAccount.setAuthenticationModes(Collections.singletonList("SSO"));
43+
newAccount.setAuthenticationModes(asList(SSO.toString(), PASSWORD.toString()));
4344
account = accountService.createAccount(newAccount, getProperty("domain"));
4445

4546
assertThat(account, is(notNullValue()));
4647
assertThat(account.getId(), is(notNullValue()));
4748
assertThat(account.getLogin(), is(LOGIN));
48-
assertThat(account.getAuthenticationModes(), is(Collections.singletonList("SSO")));
49+
assertThat(account.getAuthenticationModes(), containsInAnyOrder(SSO.toString(), PASSWORD.toString()));
4950
}
5051

5152
@Test(groups = "isolated_domain", dependsOnMethods = "createAccount")
@@ -69,7 +70,7 @@ public void getSeparatorSettings() {
6970
}
7071

7172
@Test(groups = "isolated_domain", dependsOnMethods = "getSeparatorSettings")
72-
public void updateAccount() throws Exception {
73+
public void updateAccount() {
7374
final String newName = "Petra";
7475
account.setFirstName(newName);
7576

gooddata-java/src/test/java/com/gooddata/sdk/service/account/AccountServiceIT.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
import org.testng.annotations.BeforeClass;
1313
import org.testng.annotations.Test;
1414

15-
import java.io.IOException;
1615
import java.util.Collections;
1716
import java.util.List;
1817

1918
import static com.gooddata.sdk.common.util.ResourceUtils.*;
19+
import static com.gooddata.sdk.model.account.Account.AuthenticationMode.SSO;
2020
import static net.jadler.Jadler.onRequest;
2121
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
2222
import static org.hamcrest.MatcherAssert.assertThat;
@@ -40,13 +40,13 @@ public class AccountServiceIT extends AbstractGoodDataIT {
4040
private static Account createAccount;
4141

4242
@BeforeClass
43-
public void init() throws IOException {
43+
public void init() {
4444
account = readObjectFromResource(ACCOUNT, Account.class);
4545
createAccount = readObjectFromResource(CREATE_ACCOUNT, Account.class);
4646
}
4747

4848
@Test
49-
public void shouldCreateAccount() throws Exception {
49+
public void shouldCreateAccount() {
5050
onRequest()
5151
.havingMethodEqualTo("POST")
5252
.havingPathEqualTo(AccountService.ACCOUNTS_TEMPLATE.expand(DOMAIN).toString())
@@ -79,7 +79,7 @@ public void shouldFailToCreateAccount() {
7979
}
8080

8181
@Test
82-
public void shouldRemoveAccount() throws Exception {
82+
public void shouldRemoveAccount() {
8383
onRequest()
8484
.havingMethodEqualTo("DELETE")
8585
.havingPathEqualTo(ACCOUNT_URI)
@@ -90,7 +90,7 @@ public void shouldRemoveAccount() throws Exception {
9090
}
9191

9292
@Test(expectedExceptions = AccountNotFoundException.class)
93-
public void shouldFailToFindAccountForRemoval() throws Exception {
93+
public void shouldFailToFindAccountForRemoval() {
9494
onRequest()
9595
.havingMethodEqualTo("DELETE")
9696
.havingPathEqualTo(ACCOUNT_URI)
@@ -116,7 +116,7 @@ public void shouldGetCurrentAccount() {
116116
}
117117

118118
@Test(expectedExceptions = GoodDataException.class)
119-
public void shouldFailToGetCurrentAccount() throws Exception {
119+
public void shouldFailToGetCurrentAccount() {
120120
onRequest()
121121
.havingMethodEqualTo("GET")
122122
.havingPathEqualTo(CURRENT_ACCOUNT_URI)
@@ -127,7 +127,7 @@ public void shouldFailToGetCurrentAccount() throws Exception {
127127
}
128128

129129
@Test(expectedExceptions = AccountNotFoundException.class)
130-
public void shouldFailToFindCurrentAccount() throws Exception {
130+
public void shouldFailToFindCurrentAccount() {
131131
onRequest()
132132
.havingMethodEqualTo("GET")
133133
.havingPathEqualTo(CURRENT_ACCOUNT_URI)
@@ -210,7 +210,7 @@ public void shouldFailOnUpdateNonExistentAccount() {
210210
}
211211

212212
@Test
213-
public void shouldUpdateAccount() throws Exception {
213+
public void shouldUpdateAccount() {
214214
onRequest()
215215
.havingMethodEqualTo("PUT")
216216
.havingPathEqualTo(ACCOUNT_URI)
@@ -224,7 +224,7 @@ public void shouldUpdateAccount() throws Exception {
224224
final String newEmail = "fake2@gooddata.com";
225225
final String newPass = "password2";
226226
final String newLastName = "Muhehe2";
227-
final List<String> authenticationModes = Collections.singletonList("SSO");
227+
final List<String> authenticationModes = Collections.singletonList(SSO.toString());
228228

229229
toBeUpdated.setFirstName(newFirstName);
230230
toBeUpdated.setEmail(newEmail);

0 commit comments

Comments
 (0)