@webex/webex-core 3.12.0-llmrefactor.1 → 3.12.0-llmrefactor.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/config.js +23 -0
  2. package/dist/config.js.map +1 -1
  3. package/dist/index.js +7 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/interceptors/catalog-url.js +87 -0
  6. package/dist/interceptors/catalog-url.js.map +1 -0
  7. package/dist/interceptors/payload-transformer.js +25 -4
  8. package/dist/interceptors/payload-transformer.js.map +1 -1
  9. package/dist/lib/batcher.js +1 -1
  10. package/dist/lib/credentials/credentials.js +56 -1
  11. package/dist/lib/credentials/credentials.js.map +1 -1
  12. package/dist/lib/credentials/token.js +1 -1
  13. package/dist/lib/services/service-catalog.js +102 -8
  14. package/dist/lib/services/service-catalog.js.map +1 -1
  15. package/dist/lib/services/services.js +74 -44
  16. package/dist/lib/services/services.js.map +1 -1
  17. package/dist/lib/services-v2/service-catalog.js +8 -1
  18. package/dist/lib/services-v2/service-catalog.js.map +1 -1
  19. package/dist/lib/services-v2/services-v2.js +76 -45
  20. package/dist/lib/services-v2/services-v2.js.map +1 -1
  21. package/dist/plugins/logger.js +1 -1
  22. package/dist/webex-core.js +11 -3
  23. package/dist/webex-core.js.map +1 -1
  24. package/package.json +12 -12
  25. package/src/config.js +25 -0
  26. package/src/index.js +1 -0
  27. package/src/interceptors/catalog-url.js +66 -0
  28. package/src/interceptors/payload-transformer.js +23 -1
  29. package/src/lib/credentials/credentials.js +43 -0
  30. package/src/lib/services/service-catalog.js +106 -6
  31. package/src/lib/services/services.js +65 -30
  32. package/src/lib/services-v2/service-catalog.ts +10 -1
  33. package/src/lib/services-v2/services-v2.ts +70 -30
  34. package/src/webex-core.js +8 -0
  35. package/test/integration/spec/services/services.js +148 -113
  36. package/test/integration/spec/services-v2/services-v2.js +134 -99
  37. package/test/unit/spec/credentials/credentials.js +114 -1
  38. package/test/unit/spec/interceptors/catalog-url.js +224 -0
  39. package/test/unit/spec/interceptors/payload-transformer.js +119 -1
  40. package/test/unit/spec/services/service-catalog.js +275 -0
  41. package/test/unit/spec/services/services.js +135 -2
  42. package/test/unit/spec/services-v2/service-catalog.ts +41 -0
  43. package/test/unit/spec/services-v2/services-v2.ts +158 -2
  44. package/test/unit/spec/webex-core.js +77 -1
@@ -5,7 +5,7 @@
5
5
  import '@webex/internal-plugin-device';
6
6
 
7
7
  import {assert} from '@webex/test-helper-chai';
8
- import {flaky} from '@webex/test-helper-mocha';
8
+ import {flaky, retryOn429} from '@webex/test-helper-mocha';
9
9
  import WebexCore, {
10
10
  ServiceCatalog,
11
11
  ServiceRegistry,
@@ -443,7 +443,10 @@ describe('webex-core', () => {
443
443
  // Before init settles, webex.ready must be false because services.ready
444
444
  // is a dependency and starts false in the gated path.
445
445
  assert.isFalse(gatedWebex.internal.services.ready, 'services.ready should start false');
446
- assert.isFalse(gatedWebex.ready, 'webex.ready should not fire while services.ready is false');
446
+ assert.isFalse(
447
+ gatedWebex.ready,
448
+ 'webex.ready should not fire while services.ready is false'
449
+ );
447
450
 
448
451
  // Wait up to 30s for services init to complete and flip ready.
449
452
  await new Promise((resolve, reject) => {
@@ -463,7 +466,10 @@ describe('webex-core', () => {
463
466
  });
464
467
  });
465
468
 
466
- assert.isTrue(gatedWebex.internal.services.ready, 'services.ready should flip true after init settles');
469
+ assert.isTrue(
470
+ gatedWebex.internal.services.ready,
471
+ 'services.ready should flip true after init settles'
472
+ );
467
473
  assert.isTrue(gatedWebex.ready, 'webex.ready should fire once services.ready flips');
468
474
  });
469
475
  });
@@ -903,18 +909,22 @@ describe('webex-core', () => {
903
909
  }));
904
910
 
905
911
  it('validates an authorized user and webex instance', () =>
906
- services.validateUser({email: webexUser.email}).then((r) => {
907
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
908
- assert.equal(r.activated, true);
909
- assert.equal(r.exists, true);
910
- }));
912
+ retryOn429(() =>
913
+ services.validateUser({email: webexUser.email}).then((r) => {
914
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
915
+ assert.equal(r.activated, true);
916
+ assert.equal(r.exists, true);
917
+ })
918
+ ));
911
919
 
912
920
  it('validates an authorized EU user and webex instance', () =>
913
- servicesEU.validateUser({email: webexUserEU.email}).then((r) => {
914
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
915
- assert.equal(r.activated, true);
916
- assert.equal(r.exists, true);
917
- }));
921
+ retryOn429(() =>
922
+ servicesEU.validateUser({email: webexUserEU.email}).then((r) => {
923
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
924
+ assert.equal(r.activated, true);
925
+ assert.equal(r.exists, true);
926
+ })
927
+ ));
918
928
 
919
929
  it("returns a rejected promise if the provided email isn't valid", () =>
920
930
  unauthServices
@@ -927,131 +937,152 @@ describe('webex-core', () => {
927
937
  }));
928
938
 
929
939
  it('validates a non-existing user', () =>
930
- unauthServices
931
- .validateUser({email: createActivationEmail()})
932
- .then((r) => {
940
+ retryOn429(() =>
941
+ unauthServices.validateUser({email: createActivationEmail()}).then((r) => {
933
942
  assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
934
943
  assert.equal(r.activated, false);
935
944
  assert.equal(r.exists, false);
936
945
  assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
937
946
  assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
938
947
  assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
939
- }));
948
+ })
949
+ ));
940
950
 
941
951
  it('validates new user with activationOptions suppressEmail false', () =>
942
- unauthServices
943
- .validateUser({
944
- email: createActivationEmail(),
945
- activationOptions: {suppressEmail: false},
946
- })
947
- .then((r) => {
948
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
949
- assert.equal(r.activated, false);
950
- assert.equal(r.exists, false);
951
- assert.equal(r.user.verificationEmailTriggered, true);
952
- assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
953
- assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
954
- assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
955
- }));
952
+ retryOn429(() =>
953
+ unauthServices
954
+ .validateUser({
955
+ email: createActivationEmail(),
956
+ activationOptions: {suppressEmail: false},
957
+ })
958
+ .then((r) => {
959
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
960
+ assert.equal(r.activated, false);
961
+ assert.equal(r.exists, false);
962
+ assert.equal(r.user.verificationEmailTriggered, true);
963
+ assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
964
+ assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
965
+ assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
966
+ })
967
+ ));
956
968
 
957
969
  it('validates new user with activationOptions suppressEmail true', () =>
958
- unauthServices
959
- .validateUser({
960
- email: createActivationEmail(),
961
- activationOptions: {suppressEmail: true},
962
- })
963
- .then((r) => {
964
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
965
- assert.equal(r.activated, false);
966
- assert.equal(r.exists, false);
967
- assert.equal(r.user.verificationEmailTriggered, false);
968
- assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
969
- assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
970
- assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
971
- }));
970
+ retryOn429(() =>
971
+ unauthServices
972
+ .validateUser({
973
+ email: createActivationEmail(),
974
+ activationOptions: {suppressEmail: true},
975
+ })
976
+ .then((r) => {
977
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
978
+ assert.equal(r.activated, false);
979
+ assert.equal(r.exists, false);
980
+ assert.equal(r.user.verificationEmailTriggered, false);
981
+ assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
982
+ assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
983
+ assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
984
+ })
985
+ ));
972
986
 
973
987
  it('validates an inactive user', () => {
974
988
  const inactive = 'webex.web.client+nonactivated@gmail.com';
975
989
 
976
- return unauthServices
977
- .validateUser({email: inactive, activationOptions: {suppressEmail: true}})
978
- .then((r) => {
990
+ return retryOn429(() =>
991
+ unauthServices
992
+ .validateUser({email: inactive, activationOptions: {suppressEmail: true}})
993
+ .then((r) => {
994
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
995
+ assert.equal(r.activated, false, 'activated');
996
+ assert.equal(r.exists, true, 'exists');
997
+ assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
998
+ assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
999
+ assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
1000
+ })
1001
+ ).catch(() => {
1002
+ assert(true);
1003
+ });
1004
+ });
1005
+
1006
+ it('validates an existing user', () =>
1007
+ retryOn429(() =>
1008
+ unauthServices.validateUser({email: webexUser.email}).then((r) => {
979
1009
  assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
980
- assert.equal(r.activated, false, 'activated');
981
- assert.equal(r.exists, true, 'exists');
1010
+ assert.equal(r.activated, true);
1011
+ assert.equal(r.exists, true);
982
1012
  assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
983
- assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
1013
+ assert.isAbove(Object.keys(unauthServices.list(false, 'signin')).length, 0);
984
1014
  assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
985
1015
  })
986
- .catch(() => {
987
- assert(true);
988
- });
989
- });
990
-
991
- it('validates an existing user', () =>
992
- unauthServices.validateUser({email: webexUser.email}).then((r) => {
993
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
994
- assert.equal(r.activated, true);
995
- assert.equal(r.exists, true);
996
- assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
997
- assert.isAbove(Object.keys(unauthServices.list(false, 'signin')).length, 0);
998
- assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
999
- }));
1016
+ ));
1000
1017
 
1001
1018
  it('validates an existing EU user', () =>
1002
- unauthServices.validateUser({email: webexUserEU.email}).then((r) => {
1003
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
1004
- assert.equal(r.activated, true);
1005
- assert.equal(r.exists, true);
1006
- assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
1007
- assert.isAbove(Object.keys(unauthServices.list(false, 'signin')).length, 0);
1008
- assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
1009
- }));
1019
+ retryOn429(() =>
1020
+ unauthServices.validateUser({email: webexUserEU.email}).then((r) => {
1021
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
1022
+ assert.equal(r.activated, true);
1023
+ assert.equal(r.exists, true);
1024
+ assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
1025
+ assert.isAbove(Object.keys(unauthServices.list(false, 'signin')).length, 0);
1026
+ assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
1027
+ })
1028
+ ));
1010
1029
 
1011
1030
  it('sends the prelogin user id as undefined when not specified', () => {
1012
1031
  const requestStub = sandbox.spy(unauthServices, 'request');
1013
1032
 
1014
- return unauthServices
1015
- .validateUser({
1016
- email: createActivationEmail(),
1017
- activationOptions: {suppressEmail: true},
1018
- })
1019
- .then(() => {
1020
- assert.isUndefined(getActivationRequest(requestStub).headers['x-prelogin-userid']);
1021
- });
1033
+ return retryOn429(() => {
1034
+ requestStub.resetHistory();
1035
+
1036
+ return unauthServices
1037
+ .validateUser({
1038
+ email: createActivationEmail(),
1039
+ activationOptions: {suppressEmail: true},
1040
+ })
1041
+ .then(() => {
1042
+ assert.isUndefined(getActivationRequest(requestStub).headers['x-prelogin-userid']);
1043
+ });
1044
+ });
1022
1045
  });
1023
1046
 
1024
1047
  it('sends the prelogin user id as provided when specified', () => {
1025
1048
  const requestStub = sandbox.spy(unauthServices, 'request');
1026
1049
  const preloginUserId = uuid.v4();
1027
1050
 
1028
- return unauthServices
1029
- .validateUser({
1030
- email: createActivationEmail(),
1031
- activationOptions: {suppressEmail: true},
1032
- preloginUserId,
1033
- })
1034
- .then(() => {
1035
- assert.strictEqual(
1036
- getActivationRequest(requestStub).headers['x-prelogin-userid'],
1037
- preloginUserId
1038
- );
1039
- });
1051
+ return retryOn429(() => {
1052
+ requestStub.resetHistory();
1053
+
1054
+ return unauthServices
1055
+ .validateUser({
1056
+ email: createActivationEmail(),
1057
+ activationOptions: {suppressEmail: true},
1058
+ preloginUserId,
1059
+ })
1060
+ .then(() => {
1061
+ assert.strictEqual(
1062
+ getActivationRequest(requestStub).headers['x-prelogin-userid'],
1063
+ preloginUserId
1064
+ );
1065
+ });
1066
+ });
1040
1067
  });
1041
1068
 
1042
1069
  it('uses the license service by default', () => {
1043
1070
  const requestStub = sandbox.spy(unauthServices, 'request');
1044
1071
 
1045
- return unauthServices
1046
- .validateUser({
1047
- email: createActivationEmail(),
1048
- activationOptions: {suppressEmail: true},
1049
- })
1050
- .then(() => {
1051
- const request = getActivationRequest(requestStub, false);
1052
- assert.strictEqual(request.service, 'license');
1053
- assert.strictEqual(request.resource, 'users/activations');
1054
- });
1072
+ return retryOn429(() => {
1073
+ requestStub.resetHistory();
1074
+
1075
+ return unauthServices
1076
+ .validateUser({
1077
+ email: createActivationEmail(),
1078
+ activationOptions: {suppressEmail: true},
1079
+ })
1080
+ .then(() => {
1081
+ const request = getActivationRequest(requestStub, false);
1082
+ assert.strictEqual(request.service, 'license');
1083
+ assert.strictEqual(request.resource, 'users/activations');
1084
+ });
1085
+ });
1055
1086
  });
1056
1087
 
1057
1088
  it('uses the user-onboarding service when useUserOnboardingServiceForActivations config is true', () => {
@@ -1065,16 +1096,20 @@ describe('webex-core', () => {
1065
1096
  const userOnboardingServices = userOnboardingWebex.internal.services;
1066
1097
  const requestStub = sandbox.spy(userOnboardingServices, 'request');
1067
1098
 
1068
- return userOnboardingServices
1069
- .validateUser({
1070
- email: createActivationEmail(),
1071
- activationOptions: {suppressEmail: true},
1072
- })
1073
- .then(() => {
1074
- const request = getActivationRequest(requestStub, true);
1075
- assert.strictEqual(request.service, 'user-onboarding');
1076
- assert.strictEqual(request.resource, 'api/v1/users/activations');
1077
- });
1099
+ return retryOn429(() => {
1100
+ requestStub.resetHistory();
1101
+
1102
+ return userOnboardingServices
1103
+ .validateUser({
1104
+ email: createActivationEmail(),
1105
+ activationOptions: {suppressEmail: true},
1106
+ })
1107
+ .then(() => {
1108
+ const request = getActivationRequest(requestStub, true);
1109
+ assert.strictEqual(request.service, 'user-onboarding');
1110
+ assert.strictEqual(request.resource, 'api/v1/users/activations');
1111
+ });
1112
+ });
1078
1113
  });
1079
1114
  });
1080
1115
 
@@ -5,7 +5,7 @@
5
5
  import '@webex/internal-plugin-device';
6
6
 
7
7
  import {assert} from '@webex/test-helper-chai';
8
- import {flaky} from '@webex/test-helper-mocha';
8
+ import {flaky, retryOn429} from '@webex/test-helper-mocha';
9
9
  import WebexCore, {
10
10
  ServiceCatalogV2,
11
11
  ServiceDetail,
@@ -354,7 +354,10 @@ describe('webex-core', () => {
354
354
  // Before init settles, webex.ready must be false because services.ready
355
355
  // is a dependency and starts false in the gated path.
356
356
  assert.isFalse(gatedWebex.internal.services.ready, 'services.ready should start false');
357
- assert.isFalse(gatedWebex.ready, 'webex.ready should not fire while services.ready is false');
357
+ assert.isFalse(
358
+ gatedWebex.ready,
359
+ 'webex.ready should not fire while services.ready is false'
360
+ );
358
361
 
359
362
  // Wait up to 30s for services init to complete and flip ready.
360
363
  await new Promise((resolve, reject) => {
@@ -374,7 +377,10 @@ describe('webex-core', () => {
374
377
  });
375
378
  });
376
379
 
377
- assert.isTrue(gatedWebex.internal.services.ready, 'services.ready should flip true after init settles');
380
+ assert.isTrue(
381
+ gatedWebex.internal.services.ready,
382
+ 'services.ready should flip true after init settles'
383
+ );
378
384
  assert.isTrue(gatedWebex.ready, 'webex.ready should fire once services.ready flips');
379
385
  });
380
386
  });
@@ -826,18 +832,22 @@ describe('webex-core', () => {
826
832
  }));
827
833
 
828
834
  it('validates an authorized user and webex instance', () =>
829
- services.validateUser({email: webexUser.email}).then((r) => {
830
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
831
- assert.equal(r.activated, true);
832
- assert.equal(r.exists, true);
833
- }));
835
+ retryOn429(() =>
836
+ services.validateUser({email: webexUser.email}).then((r) => {
837
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
838
+ assert.equal(r.activated, true);
839
+ assert.equal(r.exists, true);
840
+ })
841
+ ));
834
842
 
835
843
  it('validates an authorized EU user and webex instance', () =>
836
- servicesEU.validateUser({email: webexUserEU.email}).then((r) => {
837
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
838
- assert.equal(r.activated, true);
839
- assert.equal(r.exists, true);
840
- }));
844
+ retryOn429(() =>
845
+ servicesEU.validateUser({email: webexUserEU.email}).then((r) => {
846
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
847
+ assert.equal(r.activated, true);
848
+ assert.equal(r.exists, true);
849
+ })
850
+ ));
841
851
 
842
852
  it("returns a rejected promise if the provided email isn't valid", () =>
843
853
  unauthServices
@@ -850,113 +860,134 @@ describe('webex-core', () => {
850
860
  }));
851
861
 
852
862
  it('validates a non-existing user', () =>
853
- unauthServices
854
- .validateUser({email: createActivationEmail()})
855
- .then((r) => {
863
+ retryOn429(() =>
864
+ unauthServices.validateUser({email: createActivationEmail()}).then((r) => {
856
865
  assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
857
866
  assert.equal(r.activated, false);
858
867
  assert.equal(r.exists, false);
859
- }));
868
+ })
869
+ ));
860
870
 
861
871
  it('validates new user with activationOptions suppressEmail false', () =>
862
- unauthServices
863
- .validateUser({
864
- email: createActivationEmail(),
865
- activationOptions: {suppressEmail: false},
866
- })
867
- .then((r) => {
868
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
869
- assert.equal(r.activated, false);
870
- assert.equal(r.exists, false);
871
- assert.equal(r.user.verificationEmailTriggered, true);
872
- }));
872
+ retryOn429(() =>
873
+ unauthServices
874
+ .validateUser({
875
+ email: createActivationEmail(),
876
+ activationOptions: {suppressEmail: false},
877
+ })
878
+ .then((r) => {
879
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
880
+ assert.equal(r.activated, false);
881
+ assert.equal(r.exists, false);
882
+ assert.equal(r.user.verificationEmailTriggered, true);
883
+ })
884
+ ));
873
885
 
874
886
  it('validates new user with activationOptions suppressEmail true', () =>
875
- unauthServices
876
- .validateUser({
877
- email: createActivationEmail(),
878
- activationOptions: {suppressEmail: true},
879
- })
880
- .then((r) => {
881
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
882
- assert.equal(r.activated, false);
883
- assert.equal(r.exists, false);
884
- assert.equal(r.user.verificationEmailTriggered, false);
885
- }));
887
+ retryOn429(() =>
888
+ unauthServices
889
+ .validateUser({
890
+ email: createActivationEmail(),
891
+ activationOptions: {suppressEmail: true},
892
+ })
893
+ .then((r) => {
894
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
895
+ assert.equal(r.activated, false);
896
+ assert.equal(r.exists, false);
897
+ assert.equal(r.user.verificationEmailTriggered, false);
898
+ })
899
+ ));
886
900
 
887
901
  it('validates an inactive user', () => {
888
902
  const inactive = 'webex.web.client+nonactivated@gmail.com';
889
903
 
890
- return unauthServices
891
- .validateUser({email: inactive, activationOptions: {suppressEmail: true}})
892
- .then((r) => {
893
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
894
- assert.equal(r.activated, false, 'activated');
895
- assert.equal(r.exists, true, 'exists');
896
- })
897
- .catch(() => {
898
- assert(true);
899
- });
904
+ return retryOn429(() =>
905
+ unauthServices
906
+ .validateUser({email: inactive, activationOptions: {suppressEmail: true}})
907
+ .then((r) => {
908
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
909
+ assert.equal(r.activated, false, 'activated');
910
+ assert.equal(r.exists, true, 'exists');
911
+ })
912
+ ).catch(() => {
913
+ assert(true);
914
+ });
900
915
  });
901
916
 
902
917
  it('validates an existing user', () =>
903
- unauthServices.validateUser({email: webexUser.email}).then((r) => {
904
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
905
- assert.equal(r.activated, true);
906
- assert.equal(r.exists, true);
907
- }));
918
+ retryOn429(() =>
919
+ unauthServices.validateUser({email: webexUser.email}).then((r) => {
920
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
921
+ assert.equal(r.activated, true);
922
+ assert.equal(r.exists, true);
923
+ })
924
+ ));
908
925
 
909
926
  it('validates an existing EU user', () =>
910
- unauthServices.validateUser({email: webexUserEU.email}).then((r) => {
911
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
912
- assert.equal(r.activated, true);
913
- assert.equal(r.exists, true);
914
- }));
927
+ retryOn429(() =>
928
+ unauthServices.validateUser({email: webexUserEU.email}).then((r) => {
929
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
930
+ assert.equal(r.activated, true);
931
+ assert.equal(r.exists, true);
932
+ })
933
+ ));
915
934
 
916
935
  it('sends the prelogin user id as undefined when not specified', () => {
917
936
  const requestStub = sandbox.spy(unauthServices, 'request');
918
937
 
919
- return unauthServices
920
- .validateUser({
921
- email: createActivationEmail(),
922
- activationOptions: {suppressEmail: true},
923
- })
924
- .then(() => {
925
- assert.isUndefined(getActivationRequest(requestStub).headers['x-prelogin-userid']);
926
- });
938
+ return retryOn429(() => {
939
+ requestStub.resetHistory();
940
+
941
+ return unauthServices
942
+ .validateUser({
943
+ email: createActivationEmail(),
944
+ activationOptions: {suppressEmail: true},
945
+ })
946
+ .then(() => {
947
+ assert.isUndefined(getActivationRequest(requestStub).headers['x-prelogin-userid']);
948
+ });
949
+ });
927
950
  });
928
951
 
929
952
  it('sends the prelogin user id as provided when specified', () => {
930
953
  const requestStub = sandbox.spy(unauthServices, 'request');
931
954
  const preloginUserId = uuid.v4();
932
955
 
933
- return unauthServices
934
- .validateUser({
935
- email: createActivationEmail(),
936
- activationOptions: {suppressEmail: true},
937
- preloginUserId,
938
- })
939
- .then(() => {
940
- assert.strictEqual(
941
- getActivationRequest(requestStub).headers['x-prelogin-userid'],
942
- preloginUserId
943
- );
944
- });
956
+ return retryOn429(() => {
957
+ requestStub.resetHistory();
958
+
959
+ return unauthServices
960
+ .validateUser({
961
+ email: createActivationEmail(),
962
+ activationOptions: {suppressEmail: true},
963
+ preloginUserId,
964
+ })
965
+ .then(() => {
966
+ assert.strictEqual(
967
+ getActivationRequest(requestStub).headers['x-prelogin-userid'],
968
+ preloginUserId
969
+ );
970
+ });
971
+ });
945
972
  });
946
973
 
947
974
  it('uses the license service by default', () => {
948
975
  const requestStub = sandbox.spy(unauthServices, 'request');
949
976
 
950
- return unauthServices
951
- .validateUser({
952
- email: createActivationEmail(),
953
- activationOptions: {suppressEmail: true},
954
- })
955
- .then(() => {
956
- const request = getActivationRequest(requestStub, false);
957
- assert.strictEqual(request.service, 'license');
958
- assert.strictEqual(request.resource, 'users/activations');
959
- });
977
+ return retryOn429(() => {
978
+ requestStub.resetHistory();
979
+
980
+ return unauthServices
981
+ .validateUser({
982
+ email: createActivationEmail(),
983
+ activationOptions: {suppressEmail: true},
984
+ })
985
+ .then(() => {
986
+ const request = getActivationRequest(requestStub, false);
987
+ assert.strictEqual(request.service, 'license');
988
+ assert.strictEqual(request.resource, 'users/activations');
989
+ });
990
+ });
960
991
  });
961
992
 
962
993
  it('uses the user-onboarding service when useUserOnboardingServiceForActivations config is true', () => {
@@ -970,16 +1001,20 @@ describe('webex-core', () => {
970
1001
  const userOnboardingServices = userOnboardingWebex.internal.services;
971
1002
  const requestStub = sandbox.spy(userOnboardingServices, 'request');
972
1003
 
973
- return userOnboardingServices
974
- .validateUser({
975
- email: createActivationEmail(),
976
- activationOptions: {suppressEmail: true},
977
- })
978
- .then(() => {
979
- const request = getActivationRequest(requestStub, true);
980
- assert.strictEqual(request.service, 'user-onboarding');
981
- assert.strictEqual(request.resource, 'api/v1/users/activations');
982
- });
1004
+ return retryOn429(() => {
1005
+ requestStub.resetHistory();
1006
+
1007
+ return userOnboardingServices
1008
+ .validateUser({
1009
+ email: createActivationEmail(),
1010
+ activationOptions: {suppressEmail: true},
1011
+ })
1012
+ .then(() => {
1013
+ const request = getActivationRequest(requestStub, true);
1014
+ assert.strictEqual(request.service, 'user-onboarding');
1015
+ assert.strictEqual(request.resource, 'api/v1/users/activations');
1016
+ });
1017
+ });
983
1018
  });
984
1019
  });
985
1020