diff --git a/src/main/java/com/commercetools/sync/customers/helpers/CustomerBatchValidator.java b/src/main/java/com/commercetools/sync/customers/helpers/CustomerBatchValidator.java index 66da8cb15b..042379ad46 100644 --- a/src/main/java/com/commercetools/sync/customers/helpers/CustomerBatchValidator.java +++ b/src/main/java/com/commercetools/sync/customers/helpers/CustomerBatchValidator.java @@ -5,6 +5,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank; import com.commercetools.api.models.common.BaseAddress; +import com.commercetools.api.models.customer.AuthenticationMode; import com.commercetools.api.models.customer.CustomerDraft; import com.commercetools.sync.commons.helpers.BaseBatchValidator; import com.commercetools.sync.customers.CustomerSyncOptions; @@ -107,7 +108,8 @@ private boolean isValidCustomerDraft(@Nullable final CustomerDraft customerDraft handleError(format(CUSTOMER_DRAFT_KEY_NOT_SET, customerDraft.getEmail())); } else if (isBlank(customerDraft.getEmail())) { handleError(format(CUSTOMER_DRAFT_EMAIL_NOT_SET, customerDraft.getKey())); - } else if (isBlank(customerDraft.getPassword())) { + } else if (isBlank(customerDraft.getPassword()) + && customerDraft.getAuthenticationMode() != AuthenticationMode.EXTERNAL_AUTH) { handleError(format(CUSTOMER_DRAFT_PASSWORD_NOT_SET, customerDraft.getKey())); } else if (hasValidAddresses(customerDraft)) { return hasValidBillingAndShippingAddresses(customerDraft); diff --git a/src/main/java/com/commercetools/sync/customers/utils/CustomerReferenceResolutionUtils.java b/src/main/java/com/commercetools/sync/customers/utils/CustomerReferenceResolutionUtils.java index 29d8183aec..18305b022e 100644 --- a/src/main/java/com/commercetools/sync/customers/utils/CustomerReferenceResolutionUtils.java +++ b/src/main/java/com/commercetools/sync/customers/utils/CustomerReferenceResolutionUtils.java @@ -97,6 +97,7 @@ private static CustomerDraft mapToCustomerDraft( return CustomerDraftBuilder.of() .email(customer.getEmail()) .password(customer.getPassword()) + .authenticationMode(customer.getAuthenticationMode()) .customerNumber(customer.getCustomerNumber()) .key(customer.getKey()) .firstName(customer.getFirstName()) diff --git a/src/test/java/com/commercetools/sync/customers/helpers/CustomerBatchValidatorTest.java b/src/test/java/com/commercetools/sync/customers/helpers/CustomerBatchValidatorTest.java index 05efa368e7..919207b079 100644 --- a/src/test/java/com/commercetools/sync/customers/helpers/CustomerBatchValidatorTest.java +++ b/src/test/java/com/commercetools/sync/customers/helpers/CustomerBatchValidatorTest.java @@ -10,6 +10,7 @@ import com.commercetools.api.client.ProjectApiRoot; import com.commercetools.api.models.common.AddressDraftBuilder; import com.commercetools.api.models.common.BaseAddress; +import com.commercetools.api.models.customer.AuthenticationMode; import com.commercetools.api.models.customer.CustomerDraft; import com.commercetools.api.models.customer.CustomerDraftBuilder; import com.commercetools.api.models.customer_group.CustomerGroupResourceIdentifierBuilder; @@ -161,6 +162,23 @@ void validateAndCollectReferencedKeys_WithEmptyDraft_ShouldHaveEmptyResult() { assertThat(validDrafts).isEmpty(); } + @Test + void + validateAndCollectReferencedKeys_WithCustomerDraftWithEmptyPasswordAndExternalAuth_ShouldBeValid() { + final CustomerDraft customerDraft = + CustomerDraftBuilder.of() + .email("email") + .password(EMPTY) + .authenticationMode(AuthenticationMode.EXTERNAL_AUTH) + .key("key") + .build(); + + final Set validDrafts = getValidDrafts(singletonList(customerDraft)); + + assertThat(errorCallBackMessages).hasSize(0); + assertThat(validDrafts).containsExactly(customerDraft); + } + @Test void validateAndCollectReferencedKeys_WithNullAddressList_ShouldNotHaveValidationError() { final CustomerDraft customerDraft =