@@ -22,6 +22,7 @@ import (
22
22
23
23
"regexp"
24
24
25
+ "github.com/aerogear/mobile-cli/pkg/apis/mobile/v1alpha1"
25
26
mobile "github.com/aerogear/mobile-cli/pkg/client/mobile/clientset/versioned"
26
27
mcFake "github.com/aerogear/mobile-cli/pkg/client/mobile/clientset/versioned/fake"
27
28
"github.com/aerogear/mobile-cli/pkg/client/servicecatalog/clientset/versioned"
@@ -192,6 +193,88 @@ func TestClientConfigCmd_GetClientConfigCmd(t *testing.T) {
192
193
"config": {}
193
194
}
194
195
]
196
+ }`
197
+ if strings .TrimSpace (out .String ()) != expected {
198
+ return errors .New (fmt .Sprintf ("expected: '%v', got: '%v'" , expected , strings .TrimSpace (out .String ())))
199
+ }
200
+ return nil
201
+ },
202
+ }, {
203
+ name : "get client config command with services and dmz url" ,
204
+ k8Client : func () kubernetes.Interface {
205
+ fakeclient := & kFake.Clientset {}
206
+ fakeclient .AddReactor ("list" , "secrets" , func (action ktesting.Action ) (handled bool , ret runtime.Object , err error ) {
207
+ secrets := []v1.Secret {
208
+ {
209
+ ObjectMeta : metav1.ObjectMeta {
210
+ Name : "test-service" ,
211
+ Labels : map [string ]string {
212
+ "mobile" : "enabled" ,
213
+ "clientId" : "client-id" ,
214
+ },
215
+ },
216
+ Data : map [string ][]byte {
217
+ "name" : []byte ("test-service" ),
218
+ },
219
+ },
220
+ {
221
+ ObjectMeta : metav1.ObjectMeta {
222
+ Name : "keycloak" ,
223
+ Labels : map [string ]string {
224
+ "mobile" : "enabled" ,
225
+ "clientId" : "client-id" ,
226
+ },
227
+ },
228
+ Data : map [string ][]byte {
229
+ "name" : []byte ("keycloak" ),
230
+ },
231
+ },
232
+ }
233
+ secretList := & v1.SecretList {
234
+ Items : secrets ,
235
+ }
236
+ return true , secretList , nil
237
+ })
238
+ return fakeclient
239
+ },
240
+ mobileClient : func () mobile.Interface {
241
+ mc := & mcFake.Clientset {}
242
+ mc .AddReactor ("get" , "mobileclients" , func (action ktesting.Action ) (handled bool , ret runtime.Object , err error ) {
243
+ return true , & v1alpha1.MobileClient {Spec : v1alpha1.MobileClientSpec {DmzUrl : "https://test.com" }}, nil
244
+ })
245
+ return mc
246
+ },
247
+ SvcCatalogClient : func () versioned.Interface {
248
+ fake := & scFake.Clientset {}
249
+ return fake
250
+ },
251
+ namespace : "testing-ns" ,
252
+ ClusterHost : "test" ,
253
+ args : []string {"client-id" },
254
+ cobraCmd : getFakeCbrCmd (),
255
+ ExpectError : false ,
256
+ ValidateOut : func (out bytes.Buffer ) error {
257
+ expected := `{
258
+ "version": 1,
259
+ "clusterName": "test",
260
+ "namespace": "testing-ns",
261
+ "clientId": "client-id",
262
+ "services": [
263
+ {
264
+ "id": "test-service",
265
+ "name": "test-service",
266
+ "type": "",
267
+ "url": "https://test.com/test-service",
268
+ "config": {}
269
+ },
270
+ {
271
+ "id": "keycloak",
272
+ "name": "keycloak",
273
+ "type": "",
274
+ "url": "https://test.com/keycloak",
275
+ "config": {}
276
+ }
277
+ ]
195
278
}`
196
279
if strings .TrimSpace (out .String ()) != expected {
197
280
return errors .New (fmt .Sprintf ("expected: '%v', got: '%v'" , expected , strings .TrimSpace (out .String ())))
0 commit comments