|
| 1 | +/* |
| 2 | +Copyright 2017 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package controller |
| 18 | + |
| 19 | +import ( |
| 20 | + "testing" |
| 21 | + |
| 22 | + "github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1" |
| 23 | + osb "github.com/pmorie/go-open-service-broker-client/v2" |
| 24 | +) |
| 25 | + |
| 26 | +func TestBuildOriginatingIdentity(t *testing.T) { |
| 27 | + userInfo := v1beta1.UserInfo{ |
| 28 | + |
| 29 | + UID: "abcd-1234", |
| 30 | + Groups: []string{"stuff-dev", "main-eng"}, |
| 31 | + Extra: map[string]v1beta1.ExtraValue{"foo": {"bar", "baz"}}, |
| 32 | + } |
| 33 | + |
| 34 | + e := osb.OriginatingIdentity{ |
| 35 | + Platform: "kubernetes", |
| 36 | + Value: `{"foo":["bar","baz"],"groups":["stuff-dev","main-eng"],"uid":"abcd-1234","username":"[email protected]"}`, |
| 37 | + } |
| 38 | + |
| 39 | + g, err := buildOriginatingIdentity(&userInfo) |
| 40 | + |
| 41 | + if err != nil { |
| 42 | + t.Fatalf("Unexpected Error, %+v", err) |
| 43 | + } |
| 44 | + |
| 45 | + if e.Platform != g.Platform { |
| 46 | + t.Fatalf("Unexpected Platform, %s", expectedGot(e.Platform, g.Platform)) |
| 47 | + } |
| 48 | + |
| 49 | + if e.Value != g.Value { |
| 50 | + t.Fatalf("Unexpected Value, %s", expectedGot(e.Value, g.Value)) |
| 51 | + } |
| 52 | +} |
0 commit comments