Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import org.testng.annotations.BeforeClass
import org.testng.annotations.BeforeTest

import static com.stormpath.sdk.application.Applications.newCreateRequestFor
import static org.testng.AssertJUnit.assertEquals
import static org.testng.AssertJUnit.assertTrue
import static org.testng.Assert.assertEquals
import static org.testng.Assert.assertTrue

abstract class ClientIT {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,13 @@ class ApplicationIT extends ClientIT {
def dirName = uniquify("Java SDK Filter IT Dir")
def dirName2 = uniquify("Java SDK IT Dir II")

app1 = tenant.createApplication(Applications.newCreateRequestFor(app1).createDirectoryNamed(dirName).build())
app2 = tenant.createApplication(Applications.newCreateRequestFor(app2).createDirectoryNamed(dirName2).build())
app1 = tenant.createApplication(newCreateRequestFor(app1).createDirectoryNamed(dirName).build())
app2 = tenant.createApplication(newCreateRequestFor(app2).createDirectoryNamed(dirName2).build())

deleteOnTeardown(app1)
deleteOnTeardown(app2)
deleteOnTeardown(client.getResource(app1.getDefaultAccountStore().href, Directory))
deleteOnTeardown(client.getResource(app2.getDefaultAccountStore().href, Directory))

//verify that the filter search works with a combination of criteria
def foundApps2 = tenant.getApplications(Applications.where(Applications.filter('Java SDK Filter IT App')).and(Applications.description().endsWithIgnoreCase('02')))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ import org.joda.time.DateTimeZone
import org.testng.annotations.Test

import static com.stormpath.sdk.impl.challenge.TOTPService.getTotpPassword
import static org.testng.AssertJUnit.*
import static org.testng.Assert.assertEquals
import static org.testng.Assert.assertTrue
import static org.testng.Assert.assertNotNull

/**
* @since 1.1.0
*/
class GoogleAuthenticatorChallengeIT extends AbstractMultiFactorIT{
class GoogleAuthenticatorChallengeIT extends AbstractMultiFactorIT {

@Test
void testSuccessfulGoogleAuthenticatorChallenge() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import com.stormpath.sdk.phone.Phone
import com.stormpath.sdk.resource.ResourceException
import org.testng.annotations.Test

import static org.testng.AssertJUnit.assertEquals
import static org.testng.AssertJUnit.assertTrue
import static org.testng.Assert.assertEquals
import static org.testng.Assert.assertTrue

/**
* @since 1.1.0
*/
class SmsChallengeIT extends AbstractMultiFactorIT{
class SmsChallengeIT extends AbstractMultiFactorIT {

@Test
void testFailedChallenge() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ import com.stormpath.sdk.factor.sms.SmsFactor
import com.stormpath.sdk.phone.Phone
import org.testng.annotations.Test

import static org.testng.AssertJUnit.*
import static org.testng.Assert.assertEquals
import static org.testng.Assert.assertNotNull
import static org.testng.Assert.assertTrue

/**
* @since 1.1.0
*/
class SmsChallengeManualIT extends ClientIT{
class SmsChallengeManualIT extends ClientIT {

// This test and the next one (testSuccessfulChallengeVerifyChallenge) require an actual phone to complete
// Therefore they are disabled and meant to be run manually
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import com.stormpath.sdk.impl.multifactor.AbstractMultiFactorIT
import com.stormpath.sdk.resource.ResourceException
import org.testng.annotations.Test

import static org.testng.AssertJUnit.*
import static org.testng.Assert.assertEquals
import static org.testng.Assert.assertFalse
import static org.testng.Assert.assertNotNull
import static org.testng.Assert.assertTrue

/**
* @since 1.1.0
Expand All @@ -50,26 +53,26 @@ class GoogleAuthenticatorFactorIT extends AbstractMultiFactorIT{
createSmsFactor(account, VALID_PHONE_NUMBER)

def factors = account.getFactors(Factors.criteria().limitTo(50).offsetBy(0).orderByCreatedAt());
assertEquals(factors.iterator().next().account.materialized, false)
assertFalse(factors.iterator().next().account.materialized)

factors = account.getFactors(Factors.SMS.criteria().withPhone().withAccount().limitTo(50).offsetBy(0).orderByCreatedAt());
assertEquals(factors.iterator().next().account.materialized, true)
assertEquals(factors.iterator().next().phone.materialized, true)
assertEquals(factors.getProperty("items").size, 1);
factors = account.getFactors(Factors.SMS.criteria().withPhone().withAccount().limitTo(50).offsetBy(0).orderByCreatedAt())
assertTrue(factors.iterator().next().account.materialized)
assertTrue(factors.iterator().next().phone.materialized)
assertEquals(factors.getProperty("items").size, 1)

List<Factor> factorsAsList = factors.asList()
for(Factor currentFactor : factorsAsList){
if(currentFactor instanceof SmsFactor){
assertEquals(currentFactor.phone.number,VALID_PHONE_NUMBER)
for (Factor currentFactor : factorsAsList) {
if (currentFactor instanceof SmsFactor) {
assertEquals(currentFactor.phone.number, VALID_PHONE_NUMBER)
}
}

factors = account.getFactors(Factors.SMS.criteria().withPhone().limitTo(50).offsetBy(0).orderByCreatedAt());
assertEquals(factors.getProperty("items").size,1)
assertEquals(factors.getProperty("items").size, 1)
assertEquals(factors.getProperty("items").get(0).phone.number, VALID_PHONE_NUMBER)

factors = account.getFactors(Factors.GOOGLE_AUTHENTICATOR.criteria().limitTo(50).offsetBy(0).orderByCreatedAt());
assertEquals(factors.getProperty("items").size,1)
assertEquals(factors.getProperty("items").size, 1)
assertNotNull(factors.getProperty("items").get(0).secret)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import com.stormpath.sdk.account.Accounts
import com.stormpath.sdk.challenge.Challenge
import com.stormpath.sdk.challenge.sms.SmsChallenge
import com.stormpath.sdk.directory.Directory
import com.stormpath.sdk.factor.*
import com.stormpath.sdk.factor.Factor
import com.stormpath.sdk.factor.FactorOptions
import com.stormpath.sdk.factor.FactorStatus
import com.stormpath.sdk.factor.FactorVerificationStatus
import com.stormpath.sdk.factor.Factors
import com.stormpath.sdk.factor.sms.SmsFactor
import com.stormpath.sdk.factor.sms.SmsFactorOptions
import com.stormpath.sdk.impl.multifactor.AbstractMultiFactorIT
Expand All @@ -30,8 +34,12 @@ import com.stormpath.sdk.phone.Phone
import com.stormpath.sdk.phone.PhoneStatus
import com.stormpath.sdk.resource.ResourceException
import org.testng.annotations.Test

import java.lang.reflect.Field
import static org.testng.AssertJUnit.*

import static org.testng.Assert.assertEquals
import static org.testng.Assert.assertNotNull
import static org.testng.Assert.assertTrue

/**
* @since 1.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ import com.stormpath.sdk.phone.Phone
import javax.imageio.ImageIO
import java.awt.image.BufferedImage

import static org.testng.AssertJUnit.*
import static org.testng.Assert.assertEquals
import static org.testng.Assert.assertNotNull
import static org.testng.Assert.assertNull

/**
* @since 1.1.0
Expand Down Expand Up @@ -96,7 +98,7 @@ abstract class AbstractMultiFactorIT extends ClientIT{
}
}

assertEquals(URLDecoder.decode(expectedKeyUri, "UTF-8"), URLDecoder.decode(actualKeyUri, "UTF-8"))
assertEquals(URLDecoder.decode(actualKeyUri, "UTF-8"), URLDecoder.decode(expectedKeyUri, "UTF-8"))
assertNotNull(factor.getBase64QrImage())
assertBase64EncodedQRCodeEncodesString(factor.getBase64QrImage(), expectedKeyUri)

Expand Down Expand Up @@ -130,7 +132,7 @@ abstract class AbstractMultiFactorIT extends ClientIT{

protected void assertInitialChallengeFields(Challenge challenge, String expectedChallengeStatus = 'CREATED', boolean expectDefaultMessage = true) {
if (expectDefaultMessage) {
assertEquals(challenge.message,'Your verification code is ${code}')
assertEquals(challenge.message, 'Your verification code is ${code}')
}
assertEquals(challenge.status as String, expectedChallengeStatus)
assertNotNull(challenge.factor)
Expand Down
Loading