Skip to content
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 @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<CustomerDraft> validDrafts = getValidDrafts(singletonList(customerDraft));

assertThat(errorCallBackMessages).hasSize(0);
assertThat(validDrafts).containsExactly(customerDraft);
}

@Test
void validateAndCollectReferencedKeys_WithNullAddressList_ShouldNotHaveValidationError() {
final CustomerDraft customerDraft =
Expand Down
Loading