@@ -772,6 +772,11 @@ func TestGetClientConfig(t *testing.T) {
772
772
// Ignored, since not licensed.
773
773
AllowCustomThemes : bToP (false ),
774
774
},
775
+ ServiceSettings : model.ServiceSettings {
776
+ WebsocketURL : sToP ("ws://mattermost.example.com:8065" ),
777
+ WebsocketPort : iToP (80 ),
778
+ WebsocketSecurePort : iToP (443 ),
779
+ },
775
780
},
776
781
"" ,
777
782
nil ,
@@ -780,6 +785,9 @@ func TestGetClientConfig(t *testing.T) {
780
785
"EmailNotificationContentsType" : "full" ,
781
786
"AllowCustomThemes" : "true" ,
782
787
"EnforceMultifactorAuthentication" : "false" ,
788
+ "WebsocketURL" : "ws://mattermost.example.com:8065" ,
789
+ "WebsocketPort" : "80" ,
790
+ "WebsocketSecurePort" : "443" ,
783
791
},
784
792
},
785
793
{
@@ -859,8 +867,67 @@ func TestGetClientConfig(t *testing.T) {
859
867
configMap := GenerateClientConfig (testCase .config , testCase .diagnosticId , testCase .license )
860
868
for expectedField , expectedValue := range testCase .expectedFields {
861
869
actualValue , ok := configMap [expectedField ]
862
- assert .True (t , ok , fmt .Sprintf ("config does not contain %v" , expectedField ))
863
- assert .Equal (t , expectedValue , actualValue )
870
+ if assert .True (t , ok , fmt .Sprintf ("config does not contain %v" , expectedField )) {
871
+ assert .Equal (t , expectedValue , actualValue )
872
+ }
873
+ }
874
+ })
875
+ }
876
+ }
877
+
878
+ func TestGetLimitedClientConfig (t * testing.T ) {
879
+ t .Parallel ()
880
+ testCases := []struct {
881
+ description string
882
+ config * model.Config
883
+ diagnosticId string
884
+ license * model.License
885
+ expectedFields map [string ]string
886
+ }{
887
+ {
888
+ "unlicensed" ,
889
+ & model.Config {
890
+ EmailSettings : model.EmailSettings {
891
+ EmailNotificationContentsType : sToP (model .EMAIL_NOTIFICATION_CONTENTS_FULL ),
892
+ },
893
+ ThemeSettings : model.ThemeSettings {
894
+ // Ignored, since not licensed.
895
+ AllowCustomThemes : bToP (false ),
896
+ },
897
+ ServiceSettings : model.ServiceSettings {
898
+ WebsocketURL : sToP ("ws://mattermost.example.com:8065" ),
899
+ WebsocketPort : iToP (80 ),
900
+ WebsocketSecurePort : iToP (443 ),
901
+ },
902
+ },
903
+ "" ,
904
+ nil ,
905
+ map [string ]string {
906
+ "DiagnosticId" : "" ,
907
+ "EnforceMultifactorAuthentication" : "false" ,
908
+ "WebsocketURL" : "ws://mattermost.example.com:8065" ,
909
+ "WebsocketPort" : "80" ,
910
+ "WebsocketSecurePort" : "443" ,
911
+ },
912
+ },
913
+ }
914
+
915
+ for _ , testCase := range testCases {
916
+ testCase := testCase
917
+ t .Run (testCase .description , func (t * testing.T ) {
918
+ t .Parallel ()
919
+
920
+ testCase .config .SetDefaults ()
921
+ if testCase .license != nil {
922
+ testCase .license .Features .SetDefaults ()
923
+ }
924
+
925
+ configMap := GenerateLimitedClientConfig (testCase .config , testCase .diagnosticId , testCase .license )
926
+ for expectedField , expectedValue := range testCase .expectedFields {
927
+ actualValue , ok := configMap [expectedField ]
928
+ if assert .True (t , ok , fmt .Sprintf ("config does not contain %v" , expectedField )) {
929
+ assert .Equal (t , expectedValue , actualValue )
930
+ }
864
931
}
865
932
})
866
933
}
@@ -874,6 +941,10 @@ func bToP(b bool) *bool {
874
941
return & b
875
942
}
876
943
944
+ func iToP (i int ) * int {
945
+ return & i
946
+ }
947
+
877
948
func TestGetDefaultsFromStruct (t * testing.T ) {
878
949
s := struct {
879
950
TestSettings struct {
0 commit comments