-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3dcca56
commit b17e5ca
Showing
23 changed files
with
21 additions
and
916 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1433,32 +1433,6 @@ class JumioKycTest { | |
|
||
class SingaporeKycTest { | ||
|
||
@Test | ||
fun `jersey test - GET myinfoConfig v2`() { | ||
|
||
val email = "myinfo-v2-${randomInt()}@test.com" | ||
var customerId = "" | ||
try { | ||
|
||
customerId = createCustomer(name = "Test MyInfoConfig v2 Customer", email = email).id | ||
|
||
val myInfoConfig = get<MyInfoConfig> { | ||
path = "/regions/sg/kyc/myInfoConfig" | ||
this.email = email | ||
} | ||
|
||
assertEquals( | ||
"http://ext-myinfo-emulator:8080/v2/authorise" + | ||
"?client_id=STG2-MYINFO-SELF-TEST" + | ||
"&attributes=name,sex,dob,residentialstatus,nationality,mobileno,email,mailadd" + | ||
"&redirect_uri=http://localhost:3001/callback", | ||
myInfoConfig.url) | ||
|
||
} finally { | ||
StripePayment.deleteCustomer(customerId = customerId) | ||
} | ||
} | ||
|
||
@Test | ||
fun `jersey test - GET myinfoConfig v3`() { | ||
|
||
|
@@ -1485,60 +1459,6 @@ class SingaporeKycTest { | |
} | ||
} | ||
|
||
@Test | ||
fun `jersey test - GET myinfo v2`() { | ||
|
||
val email = "myinfo-v2-${randomInt()}@test.com" | ||
var customerId = "" | ||
try { | ||
|
||
customerId = createCustomer(name = "Test MyInfo v2 Customer", email = email).id | ||
|
||
run { | ||
val regionDetailsList = get<RegionDetailsList> { | ||
path = "/regions" | ||
this.email = email | ||
} | ||
regionDetailsList.forEach { | ||
assertTrue(it.status == AVAILABLE, "All regions should be in available state") | ||
assertTrue(it.simProfiles.isEmpty(), "All regions should have empty Sim profile list") | ||
} | ||
} | ||
|
||
val personData: String = get { | ||
path = "/regions/sg/kyc/myInfo/authCode" | ||
this.email = email | ||
} | ||
|
||
val expectedPersonData = """{"name":{"lastupdated":"2018-03-20","source":"1","classification":"C","value":"TAN XIAO HUI"},"sex":{"lastupdated":"2018-03-20","source":"1","classification":"C","value":"F"},"nationality":{"lastupdated":"2018-03-20","source":"1","classification":"C","value":"SG"},"dob":{"lastupdated":"2018-03-20","source":"1","classification":"C","value":"1970-05-17"},"email":{"lastupdated":"2018-08-23","source":"4","classification":"C","value":"[email protected]"},"mobileno":{"lastupdated":"2018-08-23","code":"65","source":"4","classification":"C","prefix":"+","nbr":"97399245"},"mailadd":{"country":"SG","unit":"128","street":"BEDOK NORTH AVENUE 4","lastupdated":"2018-03-20","block":"102","postal":"460102","source":"1","classification":"C","floor":"09","building":"PEARL GARDEN"},"uinfin":"S9812381D"}""" | ||
assertEquals(expectedPersonData, personData, "MyInfo PersonData do not match") | ||
|
||
run { | ||
val regionDetailsList = get<RegionDetailsList> { | ||
path = "/regions" | ||
this.email = email | ||
} | ||
|
||
val sgRegionDetails = regionDetailsList.singleOrNull { it.region.id == "sg" } | ||
assertTrue(sgRegionDetails != null, "regionDetailsList should contain sg region") | ||
|
||
val regionDetails = RegionDetails() | ||
.region(Region().id("sg").name("Singapore")) | ||
.status(PENDING) | ||
.kycStatusMap(mutableMapOf( | ||
KycType.JUMIO.name to KycStatus.PENDING, | ||
KycType.MY_INFO.name to KycStatus.APPROVED, | ||
KycType.ADDRESS.name to KycStatus.PENDING, | ||
KycType.NRIC_FIN.name to KycStatus.PENDING)) | ||
.simProfiles(SimProfileList()) | ||
|
||
assertEquals(regionDetails, sgRegionDetails, "RegionDetails do not match") | ||
} | ||
} finally { | ||
StripePayment.deleteCustomer(customerId = customerId) | ||
} | ||
} | ||
|
||
@Test | ||
fun `jersey test - GET myinfo v3`() { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -605,31 +605,6 @@ class PurchaseTest { | |
|
||
class SingaporeKycTest { | ||
|
||
@Test | ||
fun `okhttp test - GET myinfoConfig v2`() { | ||
|
||
val email = "myinfo-${randomInt()}@test.com" | ||
var customerId = "" | ||
try { | ||
|
||
customerId = createCustomer(name = "Test MyInfoConfig v2 Customer", email = email).id | ||
|
||
val client = clientForSubject(subject = email) | ||
|
||
val myInfoConfig = client.myInfoV2Config | ||
|
||
assertEquals( | ||
"http://ext-myinfo-emulator:8080/v2/authorise" + | ||
"?client_id=STG2-MYINFO-SELF-TEST" + | ||
"&attributes=name,sex,dob,residentialstatus,nationality,mobileno,email,mailadd" + | ||
"&redirect_uri=http://localhost:3001/callback", | ||
myInfoConfig.url) | ||
|
||
} finally { | ||
StripePayment.deleteCustomer(customerId = customerId) | ||
} | ||
} | ||
|
||
@Test | ||
fun `okhttp test - GET myinfoConfig v3`() { | ||
|
||
|
@@ -655,53 +630,6 @@ class SingaporeKycTest { | |
} | ||
} | ||
|
||
@Test | ||
fun `okhttp test - GET myinfo v2`() { | ||
|
||
val email = "myinfo-v2-${randomInt()}@test.com" | ||
var customerId = "" | ||
try { | ||
|
||
customerId = createCustomer(name = "Test MyInfo v2 Customer", email = email).id | ||
|
||
val client = clientForSubject(subject = email) | ||
|
||
run { | ||
val regionDetailsList = client.allRegions | ||
|
||
regionDetailsList.forEach { | ||
assertTrue(it.status == AVAILABLE, "All regions should be in available state") | ||
} | ||
} | ||
|
||
val personData: String = jacksonObjectMapper().writeValueAsString(client.getCustomerMyInfoV2Data("authCode")) | ||
|
||
val expectedPersonData = """{"name":{"lastupdated":"2018-03-20","source":"1","classification":"C","value":"TAN XIAO HUI"},"sex":{"lastupdated":"2018-03-20","source":"1","classification":"C","value":"F"},"nationality":{"lastupdated":"2018-03-20","source":"1","classification":"C","value":"SG"},"dob":{"lastupdated":"2018-03-20","source":"1","classification":"C","value":"1970-05-17"},"email":{"lastupdated":"2018-08-23","source":"4","classification":"C","value":"[email protected]"},"mobileno":{"lastupdated":"2018-08-23","code":"65","source":"4","classification":"C","prefix":"+","nbr":"97399245"},"mailadd":{"country":"SG","unit":"128","street":"BEDOK NORTH AVENUE 4","lastupdated":"2018-03-20","block":"102","postal":"460102","source":"1","classification":"C","floor":"09","building":"PEARL GARDEN"},"uinfin":"S9812381D"}""" | ||
assertEquals(expectedPersonData, personData, "MyInfo PersonData do not match") | ||
|
||
run { | ||
val regionDetailsList = client.allRegions | ||
|
||
val sgRegionIndex = regionDetailsList.indexOfFirst { it.region.id == "sg" } | ||
assertTrue(sgRegionIndex != -1, "regionDetailsList should contain sg region") | ||
|
||
val regionDetails = RegionDetails() | ||
.region(Region().id("sg").name("Singapore")) | ||
.status(PENDING) | ||
.kycStatusMap(mutableMapOf( | ||
KycType.JUMIO.name to KycStatus.PENDING, | ||
KycType.MY_INFO.name to KycStatus.APPROVED, | ||
KycType.ADDRESS.name to KycStatus.PENDING, | ||
KycType.NRIC_FIN.name to KycStatus.PENDING)) | ||
.simProfiles(SimProfileList()) | ||
|
||
assertEquals(regionDetails, regionDetailsList[sgRegionIndex], "RegionDetails do not match") | ||
} | ||
} finally { | ||
StripePayment.deleteCustomer(customerId = customerId) | ||
} | ||
} | ||
|
||
@Test | ||
fun `okhttp test - GET myinfo v3`() { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,15 +20,22 @@ import org.ostelco.prime.auth.AccessTokenPrincipal | |
import org.ostelco.prime.auth.OAuthAuthenticator | ||
import org.ostelco.prime.customer.endpoint.store.SubscriberDAO | ||
import org.ostelco.prime.customer.endpoint.util.AccessToken | ||
import org.ostelco.prime.ekyc.MyInfoKycService | ||
import org.ostelco.prime.jsonmapper.objectMapper | ||
import org.ostelco.prime.model.Identity | ||
import org.ostelco.prime.model.MyInfoApiVersion.V2 | ||
import org.ostelco.prime.model.MyInfoApiVersion.V3 | ||
import org.ostelco.prime.model.ScanInformation | ||
import org.ostelco.prime.model.ScanStatus | ||
import java.util.* | ||
import javax.inject.Named | ||
import javax.ws.rs.core.MediaType | ||
import javax.ws.rs.core.Response | ||
|
||
private val MOCK_MY_INFO_KYC_SERVICE: MyInfoKycService = Mockito.mock(MyInfoKycService::class.java) | ||
|
||
@Named("v3") | ||
class MockMyInfoKycService : MyInfoKycService by MOCK_MY_INFO_KYC_SERVICE | ||
|
||
class KycResourcesTest { | ||
|
||
private val email = "[email protected]" | ||
|
@@ -99,10 +106,10 @@ class KycResourcesTest { | |
val identityCaptor = argumentCaptor<Identity>() | ||
val authorisationCodeCaptor = argumentCaptor<String>() | ||
|
||
`when`<Either<ApiError, String>>(DAO.getCustomerMyInfoData(identityCaptor.capture(), eq(V2), authorisationCodeCaptor.capture())) | ||
`when`<Either<ApiError, String>>(DAO.getCustomerMyInfoData(identityCaptor.capture(), eq(V3), authorisationCodeCaptor.capture())) | ||
.thenReturn("{}".right()) | ||
|
||
val resp = RULE.target("regions/sg/kyc/myInfo/code123") | ||
val resp = RULE.target("regions/sg/kyc/myInfo/v3/personData/code123") | ||
.request() | ||
.header("Authorization", "Bearer ${AccessToken.withEmail(email)}") | ||
.get(Response::class.java) | ||
|
@@ -123,10 +130,10 @@ class KycResourcesTest { | |
val identityCaptor = argumentCaptor<Identity>() | ||
val authorisationCodeCaptor = argumentCaptor<String>() | ||
|
||
`when`<Either<ApiError, String>>(DAO.getCustomerMyInfoData(identityCaptor.capture(), eq(V2), authorisationCodeCaptor.capture())) | ||
`when`<Either<ApiError, String>>(DAO.getCustomerMyInfoData(identityCaptor.capture(), eq(V3), authorisationCodeCaptor.capture())) | ||
.thenReturn("{}".right()) | ||
|
||
val resp = RULE.target("regions/no/kyc/myInfo/code123") | ||
val resp = RULE.target("regions/no/kyc/myInfo/v3/personData/code123") | ||
.request() | ||
.header("Authorization", "Bearer ${AccessToken.withEmail(email)}") | ||
.get(Response::class.java) | ||
|
@@ -137,7 +144,7 @@ class KycResourcesTest { | |
|
||
@Before | ||
fun setUp() { | ||
Mockito.`when`(AUTHENTICATOR.authenticate(ArgumentMatchers.anyString())) | ||
`when`(AUTHENTICATOR.authenticate(ArgumentMatchers.anyString())) | ||
.thenReturn(Optional.of(AccessTokenPrincipal(Identity(email, "EMAIL","email")))) | ||
} | ||
|
||
|
1 change: 1 addition & 0 deletions
1
...mer-endpoint/src/test/resources/META-INF/services/org.ostelco.prime.ekyc.MyInfoKycService
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.ostelco.prime.customer.endpoint.resources.MockMyInfoKycService |
2 changes: 1 addition & 1 deletion
2
.../src/test/resources/META-INF/services/org.ostelco.prime.paymentprocessor.PaymentProcessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
org.ostelco.prime.client.api.resources.MockPaymentProcessor | ||
org.ostelco.prime.customer.endpoint.resources.MockPaymentProcessor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.