@@ -642,6 +642,62 @@ func TestInvalidCreateUser(t *testing.T) {
642
642
}, {
643
643
(& UserToCreate {}).Email ("a@a@a" ),
644
644
`malformed email string: "a@a@a"` ,
645
+ }, {
646
+ (& UserToCreate {}).MFASettings (MultiFactorSettings {
647
+ EnrolledFactors : []* MultiFactorInfo {
648
+ {
649
+ UID : "EnrollmentID" ,
650
+ PhoneNumber : "+11234567890" ,
651
+ DisplayName : "Spouse's phone number" ,
652
+ FactorID : "phone" ,
653
+ },
654
+ },
655
+ }),
656
+ `"uid" is not supported when adding second factors via "createUser()"` ,
657
+ }, {
658
+ (& UserToCreate {}).MFASettings (MultiFactorSettings {
659
+ EnrolledFactors : []* MultiFactorInfo {
660
+ {
661
+ PhoneNumber : "invalid" ,
662
+ DisplayName : "Spouse's phone number" ,
663
+ FactorID : "phone" ,
664
+ },
665
+ },
666
+ }),
667
+ `the second factor "phoneNumber" for "invalid" must be a non-empty E.164 standard compliant identifier string` ,
668
+ }, {
669
+ (& UserToCreate {}).MFASettings (MultiFactorSettings {
670
+ EnrolledFactors : []* MultiFactorInfo {
671
+ {
672
+ PhoneNumber : "+11234567890" ,
673
+ DisplayName : "Spouse's phone number" ,
674
+ FactorID : "phone" ,
675
+ EnrollmentTimestamp : time .Now ().UTC ().Unix (),
676
+ },
677
+ },
678
+ }),
679
+ `"EnrollmentTimeStamp" is not supported when adding second factors via "createUser()"` ,
680
+ }, {
681
+ (& UserToCreate {}).MFASettings (MultiFactorSettings {
682
+ EnrolledFactors : []* MultiFactorInfo {
683
+ {
684
+ PhoneNumber : "+11234567890" ,
685
+ DisplayName : "Spouse's phone number" ,
686
+ FactorID : "" ,
687
+ },
688
+ },
689
+ }),
690
+ `no factor id specified` ,
691
+ }, {
692
+ (& UserToCreate {}).MFASettings (MultiFactorSettings {
693
+ EnrolledFactors : []* MultiFactorInfo {
694
+ {
695
+ PhoneNumber : "+11234567890" ,
696
+ FactorID : "phone" ,
697
+ },
698
+ },
699
+ }),
700
+ `the second factor "displayName" for "" must be a valid non-empty string` ,
645
701
},
646
702
}
647
703
client := & Client {
@@ -713,6 +769,49 @@ var createUserCases = []struct {
713
769
{
714
770
(& UserToCreate {}).PhotoURL ("http://some.url" ),
715
771
map [string ]interface {}{"photoUrl" : "http://some.url" },
772
+ }, {
773
+ (& UserToCreate {}).MFASettings (MultiFactorSettings {
774
+ EnrolledFactors : []* MultiFactorInfo {
775
+ {
776
+ PhoneNumber : "+11234567890" ,
777
+ DisplayName : "Spouse's phone number" ,
778
+ FactorID : "phone" ,
779
+ },
780
+ },
781
+ }),
782
+ map [string ]interface {}{"mfaInfo" : []* multiFactorInfoResponse {
783
+ {
784
+ PhoneInfo : "+11234567890" ,
785
+ DisplayName : "Spouse's phone number" ,
786
+ },
787
+ },
788
+ },
789
+ }, {
790
+ (& UserToCreate {}).MFASettings (MultiFactorSettings {
791
+ EnrolledFactors : []* MultiFactorInfo {
792
+ {
793
+ PhoneNumber : "+11234567890" ,
794
+ DisplayName : "number1" ,
795
+ FactorID : "phone" ,
796
+ },
797
+ {
798
+ PhoneNumber : "+11234567890" ,
799
+ DisplayName : "number2" ,
800
+ FactorID : "phone" ,
801
+ },
802
+ },
803
+ }),
804
+ map [string ]interface {}{"mfaInfo" : []* multiFactorInfoResponse {
805
+ {
806
+ PhoneInfo : "+11234567890" ,
807
+ DisplayName : "number1" ,
808
+ },
809
+ {
810
+ PhoneInfo : "+11234567890" ,
811
+ DisplayName : "number2" ,
812
+ },
813
+ },
814
+ },
716
815
},
717
816
}
718
817
@@ -772,6 +871,40 @@ func TestInvalidUpdateUser(t *testing.T) {
772
871
}, {
773
872
(& UserToUpdate {}).Password ("short" ),
774
873
"password must be a string at least 6 characters long" ,
874
+ }, {
875
+ (& UserToUpdate {}).MFASettings (MultiFactorSettings {
876
+ EnrolledFactors : []* MultiFactorInfo {
877
+ {
878
+ UID : "enrolledSecondFactor1" ,
879
+ PhoneNumber : "+11234567890" ,
880
+ FactorID : "phone" ,
881
+ },
882
+ },
883
+ }),
884
+ `the second factor "displayName" for "" must be a valid non-empty string` ,
885
+ }, {
886
+ (& UserToUpdate {}).MFASettings (MultiFactorSettings {
887
+ EnrolledFactors : []* MultiFactorInfo {
888
+ {
889
+ UID : "enrolledSecondFactor1" ,
890
+ PhoneNumber : "invalid" ,
891
+ DisplayName : "Spouse's phone number" ,
892
+ FactorID : "phone" ,
893
+ },
894
+ },
895
+ }),
896
+ `the second factor "phoneNumber" for "invalid" must be a non-empty E.164 standard compliant identifier string` ,
897
+ }, {
898
+ (& UserToUpdate {}).MFASettings (MultiFactorSettings {
899
+ EnrolledFactors : []* MultiFactorInfo {
900
+ {
901
+ PhoneNumber : "+11234567890" ,
902
+ FactorID : "phone" ,
903
+ DisplayName : "Spouse's phone number" ,
904
+ },
905
+ },
906
+ }),
907
+ `the second factor "uid" must be a valid non-empty string when adding second factors via "updateUser()"` ,
775
908
}, {
776
909
(& UserToUpdate {}).ProviderToLink (& UserProvider {UID : "google_uid" }),
777
910
"user provider must specify a provider ID" ,
@@ -912,6 +1045,42 @@ var updateUserCases = []struct {
912
1045
"deleteProvider" : []string {"phone" },
913
1046
},
914
1047
},
1048
+ {
1049
+ (& UserToUpdate {}).MFASettings (MultiFactorSettings {
1050
+ EnrolledFactors : []* MultiFactorInfo {
1051
+ {
1052
+ UID : "enrolledSecondFactor1" ,
1053
+ PhoneNumber : "+11234567890" ,
1054
+ DisplayName : "Spouse's phone number" ,
1055
+ FactorID : "phone" ,
1056
+ EnrollmentTimestamp : time .Now ().Unix (),
1057
+ }, {
1058
+ UID : "enrolledSecondFactor2" ,
1059
+ PhoneNumber : "+11234567890" ,
1060
+ DisplayName : "Spouse's phone number" ,
1061
+ FactorID : "phone" ,
1062
+ },
1063
+ },
1064
+ }),
1065
+ map [string ]interface {}{"mfaInfo" : []* multiFactorInfoResponse {
1066
+ {
1067
+ MFAEnrollmentID : "enrolledSecondFactor1" ,
1068
+ PhoneInfo : "+11234567890" ,
1069
+ DisplayName : "Spouse's phone number" ,
1070
+ EnrolledAt : time .Now ().Format ("2006-01-02T15:04:05Z07:00Z" ),
1071
+ },
1072
+ {
1073
+ MFAEnrollmentID : "enrolledSecondFactor2" ,
1074
+ DisplayName : "Spouse's phone number" ,
1075
+ PhoneInfo : "+11234567890" ,
1076
+ },
1077
+ },
1078
+ },
1079
+ },
1080
+ {
1081
+ (& UserToUpdate {}).MFASettings (MultiFactorSettings {}),
1082
+ map [string ]interface {}{"mfaInfo" : nil },
1083
+ },
915
1084
{
916
1085
(& UserToUpdate {}).ProviderToLink (& UserProvider {
917
1086
ProviderID : "google.com" ,
0 commit comments