@@ -126,6 +126,87 @@ ALLOWED_USER_VISIBILITY_MODES = public, limit, privated
126
126
}
127
127
}
128
128
129
+ func TestLoadServiceOrgVisibilityModes (t * testing.T ) {
130
+ defer test .MockVariableValue (& Service )()
131
+
132
+ kases := map [string ]func (){
133
+ `
134
+ [service]
135
+ DEFAULT_ORG_VISIBILITY = public
136
+ ALLOWED_ORG_VISIBILITY_MODES = public,limited,private
137
+ ` : func () {
138
+ assert .Equal (t , "public" , Service .DefaultOrgVisibility )
139
+ assert .Equal (t , structs .VisibleTypePublic , Service .DefaultOrgVisibilityMode )
140
+ assert .Equal (t , []string {"public" , "limited" , "private" }, Service .AllowedOrgVisibilityModes )
141
+ },
142
+ `
143
+ [service]
144
+ DEFAULT_ORG_VISIBILITY = public
145
+ ` : func () {
146
+ assert .Equal (t , "public" , Service .DefaultOrgVisibility )
147
+ assert .Equal (t , structs .VisibleTypePublic , Service .DefaultOrgVisibilityMode )
148
+ assert .Equal (t , []string {"public" , "limited" , "private" }, Service .AllowedOrgVisibilityModes )
149
+ },
150
+ `
151
+ [service]
152
+ DEFAULT_ORG_VISIBILITY = limited
153
+ ` : func () {
154
+ assert .Equal (t , "limited" , Service .DefaultOrgVisibility )
155
+ assert .Equal (t , structs .VisibleTypeLimited , Service .DefaultOrgVisibilityMode )
156
+ assert .Equal (t , []string {"public" , "limited" , "private" }, Service .AllowedOrgVisibilityModes )
157
+ },
158
+ `
159
+ [service]
160
+ ALLOWED_ORG_VISIBILITY_MODES = public,limited,private
161
+ ` : func () {
162
+ assert .Equal (t , "public" , Service .DefaultOrgVisibility )
163
+ assert .Equal (t , structs .VisibleTypePublic , Service .DefaultOrgVisibilityMode )
164
+ assert .Equal (t , []string {"public" , "limited" , "private" }, Service .AllowedOrgVisibilityModes )
165
+ },
166
+ `
167
+ [service]
168
+ DEFAULT_ORG_VISIBILITY = public
169
+ ALLOWED_ORG_VISIBILITY_MODES = limited,private
170
+ ` : func () {
171
+ assert .Equal (t , "limited" , Service .DefaultOrgVisibility )
172
+ assert .Equal (t , structs .VisibleTypeLimited , Service .DefaultOrgVisibilityMode )
173
+ assert .Equal (t , []string {"limited" , "private" }, Service .AllowedOrgVisibilityModes )
174
+ },
175
+ `
176
+ [service]
177
+ DEFAULT_ORG_VISIBILITY = my_type
178
+ ALLOWED_ORG_VISIBILITY_MODES = limited,private
179
+ ` : func () {
180
+ assert .Equal (t , "limited" , Service .DefaultOrgVisibility )
181
+ assert .Equal (t , structs .VisibleTypeLimited , Service .DefaultOrgVisibilityMode )
182
+ assert .Equal (t , []string {"limited" , "private" }, Service .AllowedOrgVisibilityModes )
183
+ },
184
+ `
185
+ [service]
186
+ DEFAULT_ORG_VISIBILITY = public
187
+ ALLOWED_ORG_VISIBILITY_MODES = public, limit, privated
188
+ ` : func () {
189
+ assert .Equal (t , "public" , Service .DefaultOrgVisibility )
190
+ assert .Equal (t , structs .VisibleTypePublic , Service .DefaultOrgVisibilityMode )
191
+ assert .Equal (t , []string {"public" }, Service .AllowedOrgVisibilityModes )
192
+ },
193
+ }
194
+
195
+ for kase , fun := range kases {
196
+ t .Run (kase , func (t * testing.T ) {
197
+ cfg , err := NewConfigProviderFromData (kase )
198
+ assert .NoError (t , err )
199
+ loadServiceFrom (cfg )
200
+ fun ()
201
+ // reset
202
+ Service .AllowedOrgVisibilityModesSlice = []bool {true , true , true }
203
+ Service .AllowedOrgVisibilityModes = []string {}
204
+ Service .DefaultOrgVisibility = ""
205
+ Service .DefaultOrgVisibilityMode = structs .VisibleTypePublic
206
+ })
207
+ }
208
+ }
209
+
129
210
func TestLoadServiceRequireSignInView (t * testing.T ) {
130
211
defer test .MockVariableValue (& Service )()
131
212
0 commit comments