Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit 1b85d12

Browse files
authored
Merge pull request #1179 from stormpath/issue/1159
Issue/1159
2 parents 2e6b2f0 + dfea093 commit 1b85d12

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

extensions/servlet/src/main/java/com/stormpath/sdk/servlet/mvc/provider/ExternalAccountStoreModelFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.stormpath.sdk.application.ApplicationAccountStoreMappingList;
2222
import com.stormpath.sdk.application.ApplicationAccountStoreMappings;
2323
import com.stormpath.sdk.application.webconfig.ApplicationWebConfig;
24+
import com.stormpath.sdk.application.webconfig.ApplicationWebConfigStatus;
2425
import com.stormpath.sdk.directory.AccountStore;
2526
import com.stormpath.sdk.directory.AccountStoreVisitor;
2627
import com.stormpath.sdk.directory.Directory;
@@ -73,7 +74,7 @@ public List<AccountStoreModel> getAccountStores(HttpServletRequest request) {
7374
@SuppressWarnings("WeakerAccess") // Want to allow overriding this method
7475
protected String getAuthorizeBaseUri(@SuppressWarnings("UnusedParameters") HttpServletRequest request, ApplicationWebConfig webConfig) {
7576
String authorizeBaseUri = null;
76-
if (webConfig.getLogin().isEnabled()) {
77+
if (webConfig.getStatus() == ApplicationWebConfigStatus.ENABLED && webConfig.getLogin().isEnabled()) {
7778
authorizeBaseUri = "https://" + webConfig.getDomainName();
7879
}
7980
return authorizeBaseUri;

extensions/servlet/src/test/groovy/com/stormpath/sdk/servlet/mvc/provider/ExternalAccountStoreModelFactoryTest.groovy

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.stormpath.sdk.application.ApplicationAccountStoreMapping
55
import com.stormpath.sdk.application.ApplicationAccountStoreMappingCriteria
66
import com.stormpath.sdk.application.ApplicationAccountStoreMappingList
77
import com.stormpath.sdk.application.webconfig.ApplicationWebConfig
8+
import com.stormpath.sdk.application.webconfig.ApplicationWebConfigStatus
89
import com.stormpath.sdk.application.webconfig.LoginConfig
910
import com.stormpath.sdk.directory.AccountStoreVisitor
1011
import com.stormpath.sdk.directory.Directory
@@ -29,6 +30,7 @@ import static org.hamcrest.Matchers.containsString
2930
import static org.hamcrest.Matchers.instanceOf
3031
import static org.hamcrest.Matchers.nullValue
3132
import static org.hamcrest.Matchers.startsWith
33+
import static org.testng.Assert.assertNull
3234

3335
class ExternalAccountStoreModelFactoryTest {
3436
static final String WEB_CONFIG_DOMAIN_NAME = "blah-blah.apps.stormpath.io"
@@ -39,6 +41,7 @@ class ExternalAccountStoreModelFactoryTest {
3941
MockHttpServletRequest request
4042
Application application
4143
ApplicationWebConfig applicationWebConfig
44+
ApplicationWebConfigStatus applicationWebConfigEnabled
4245
LoginConfig loginConfig
4346
boolean loginConfigEnabled
4447

@@ -70,7 +73,14 @@ class ExternalAccountStoreModelFactoryTest {
7073
return loginConfigEnabled
7174
}
7275
})
76+
applicationWebConfigEnabled = ApplicationWebConfigStatus.DISABLED
7377
applicationWebConfig = createNiceMock(ApplicationWebConfig)
78+
expect(applicationWebConfig.getStatus()).andStubAnswer(new IAnswer<ApplicationWebConfigStatus>() {
79+
@Override
80+
ApplicationWebConfigStatus answer() throws Throwable {
81+
return applicationWebConfigEnabled
82+
}
83+
})
7484
expect(applicationWebConfig.login).andStubReturn(loginConfig)
7585
expect(applicationWebConfig.domainName).andStubReturn(WEB_CONFIG_DOMAIN_NAME)
7686

@@ -190,7 +200,8 @@ class ExternalAccountStoreModelFactoryTest {
190200
}
191201

192202
@Test
193-
void testOAuthAccountStoreMappingWithWebConfigLoginEnabled() {
203+
void testOAuthAccountStoreMappingWithWebConfigEnabledLoginEnabled() {
204+
applicationWebConfigEnabled = ApplicationWebConfigStatus.ENABLED
194205
loginConfigEnabled = true
195206
addMapping(facebookAccountStore)
196207
def actual = factoryUT.getAccountStores(request)
@@ -203,6 +214,20 @@ class ExternalAccountStoreModelFactoryTest {
203214
assertThat("authorizeUri", accountStoreModel.authorizeUri, startsWith("https://${WEB_CONFIG_DOMAIN_NAME}/authorize"))
204215
}
205216

217+
// test to verify fix for https://github.com/stormpath/stormpath-sdk-java/issues/1159
218+
@Test
219+
void testOAuthAccountStoreMappingWithWebConfigDisabledLoginEnabled() {
220+
applicationWebConfigEnabled = ApplicationWebConfigStatus.DISABLED
221+
loginConfigEnabled = true
222+
addMapping(facebookAccountStore)
223+
def actual = factoryUT.getAccountStores(request)
224+
225+
assertThat(actual, Matchers.hasSize(1))
226+
def accountStoreModel = actual[0]
227+
assertThat(accountStoreModel.provider, instanceOf(DefaultOAuthProviderModel))
228+
assertNull(accountStoreModel.authorizeUri)
229+
}
230+
206231
private ApplicationAccountStoreMapping addMapping(Directory directory) {
207232
ApplicationAccountStoreMapping mapping = createNiceMock(ApplicationAccountStoreMapping)
208233
expect(mapping.application).andStubReturn(application)

0 commit comments

Comments
 (0)