Skip to content

Commit

Permalink
Fix missing type in the PutCustomerRequest in SEP-24 post transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
lijamie98 committed Jun 15, 2023
1 parent 2c2f2ef commit 7251624
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.stellar.anchor.util.GsonUtils;

public class SimpleInteractiveUrlConstructor extends InteractiveUrlConstructor {
public static final String FORWARD_KYC_CUSTOMER_TYPE = "sep24-customer";
private final PropertySep24Config sep24Config;
private final CustomerIntegration customerIntegration;
private final JwtService jwtService;
Expand Down Expand Up @@ -95,6 +96,7 @@ void forwardKycFields(Map<String, String> request) throws AnchorException {
String gsonRequest = gson.toJson(sep9);
PutCustomerRequest putCustomerRequest =
gson.fromJson(gsonRequest, PutCustomerRequest.class);
putCustomerRequest.setType(FORWARD_KYC_CUSTOMER_TYPE);
// forward kyc fields to PUT /customer
customerIntegration.putCustomer(putCustomerRequest);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.mockk
import io.mockk.slot
import io.mockk.verify
import java.time.Instant
import java.util.stream.Stream
import org.junit.jupiter.api.Assertions.*
Expand Down Expand Up @@ -77,7 +78,21 @@ class SimpleInteractiveUrlConstructorTest {
every { customerIntegration.putCustomer(capture(capturedPutCustomerRequest)) } returns
PutCustomerResponse()
val constructor = SimpleInteractiveUrlConstructor(sep24Config, customerIntegration, jwtService)
sep24Config.kycFieldsForwarding.isEnabled = true
constructor.construct(txn, request as HashMap<String, String>?)
assertEquals(capturedPutCustomerRequest.captured.type, "sep24-customer")
assertEquals(capturedPutCustomerRequest.captured.firstName, request.get("first_name"))
assertEquals(capturedPutCustomerRequest.captured.lastName, request.get("last_name"))
assertEquals(capturedPutCustomerRequest.captured.emailAddress, request.get("email_address"))
}

@Test
fun `when kycFieldsForwarding is disabled, the customerIntegration should not receive the kyc fields`() {
val customerIntegration: CustomerIntegration = mockk()
val constructor = SimpleInteractiveUrlConstructor(sep24Config, customerIntegration, jwtService)
sep24Config.kycFieldsForwarding.isEnabled = false
constructor.construct(txn, request as HashMap<String, String>?)
verify(exactly = 0) { customerIntegration.putCustomer(any()) }
}

private fun parseJwtFromUrl(url: String?): Sep24InteractiveUrlJwt {
Expand Down

0 comments on commit 7251624

Please sign in to comment.