File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
main/java/com/commercetools/sync/customers
test/java/com/commercetools/sync/customers/helpers Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 55import static org .apache .commons .lang3 .StringUtils .isBlank ;
66
77import com .commercetools .api .models .common .BaseAddress ;
8+ import com .commercetools .api .models .customer .AuthenticationMode ;
89import com .commercetools .api .models .customer .CustomerDraft ;
910import com .commercetools .sync .commons .helpers .BaseBatchValidator ;
1011import com .commercetools .sync .customers .CustomerSyncOptions ;
@@ -107,7 +108,8 @@ private boolean isValidCustomerDraft(@Nullable final CustomerDraft customerDraft
107108 handleError (format (CUSTOMER_DRAFT_KEY_NOT_SET , customerDraft .getEmail ()));
108109 } else if (isBlank (customerDraft .getEmail ())) {
109110 handleError (format (CUSTOMER_DRAFT_EMAIL_NOT_SET , customerDraft .getKey ()));
110- } else if (isBlank (customerDraft .getPassword ())) {
111+ } else if (isBlank (customerDraft .getPassword ())
112+ && customerDraft .getAuthenticationMode () != AuthenticationMode .EXTERNAL_AUTH ) {
111113 handleError (format (CUSTOMER_DRAFT_PASSWORD_NOT_SET , customerDraft .getKey ()));
112114 } else if (hasValidAddresses (customerDraft )) {
113115 return hasValidBillingAndShippingAddresses (customerDraft );
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ private static CustomerDraft mapToCustomerDraft(
9797 return CustomerDraftBuilder .of ()
9898 .email (customer .getEmail ())
9999 .password (customer .getPassword ())
100+ .authenticationMode (customer .getAuthenticationMode ())
100101 .customerNumber (customer .getCustomerNumber ())
101102 .key (customer .getKey ())
102103 .firstName (customer .getFirstName ())
Original file line number Diff line number Diff line change 1010import com .commercetools .api .client .ProjectApiRoot ;
1111import com .commercetools .api .models .common .AddressDraftBuilder ;
1212import com .commercetools .api .models .common .BaseAddress ;
13+ import com .commercetools .api .models .customer .AuthenticationMode ;
1314import com .commercetools .api .models .customer .CustomerDraft ;
1415import com .commercetools .api .models .customer .CustomerDraftBuilder ;
1516import com .commercetools .api .models .customer_group .CustomerGroupResourceIdentifierBuilder ;
@@ -161,6 +162,23 @@ void validateAndCollectReferencedKeys_WithEmptyDraft_ShouldHaveEmptyResult() {
161162 assertThat (validDrafts ).isEmpty ();
162163 }
163164
165+ @ Test
166+ void
167+ validateAndCollectReferencedKeys_WithCustomerDraftWithEmptyPasswordAndExternalAuth_ShouldBeValid () {
168+ final CustomerDraft customerDraft =
169+ CustomerDraftBuilder .of ()
170+ .email ("email" )
171+ .password (EMPTY )
172+ .authenticationMode (AuthenticationMode .EXTERNAL_AUTH )
173+ .key ("key" )
174+ .build ();
175+
176+ final Set <CustomerDraft > validDrafts = getValidDrafts (singletonList (customerDraft ));
177+
178+ assertThat (errorCallBackMessages ).hasSize (0 );
179+ assertThat (validDrafts ).containsExactly (customerDraft );
180+ }
181+
164182 @ Test
165183 void validateAndCollectReferencedKeys_WithNullAddressList_ShouldNotHaveValidationError () {
166184 final CustomerDraft customerDraft =
You can’t perform that action at this time.
0 commit comments