@@ -5,6 +5,7 @@ import com.stormpath.sdk.application.ApplicationAccountStoreMapping
55import com.stormpath.sdk.application.ApplicationAccountStoreMappingCriteria
66import com.stormpath.sdk.application.ApplicationAccountStoreMappingList
77import com.stormpath.sdk.application.webconfig.ApplicationWebConfig
8+ import com.stormpath.sdk.application.webconfig.ApplicationWebConfigStatus
89import com.stormpath.sdk.application.webconfig.LoginConfig
910import com.stormpath.sdk.directory.AccountStoreVisitor
1011import com.stormpath.sdk.directory.Directory
@@ -29,6 +30,7 @@ import static org.hamcrest.Matchers.containsString
2930import static org.hamcrest.Matchers.instanceOf
3031import static org.hamcrest.Matchers.nullValue
3132import static org.hamcrest.Matchers.startsWith
33+ import static org.testng.Assert.assertNull
3234
3335class 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