Select Git revision
release-notes.md
utils_test.go 9.49 KiB
/*
Copyright 2015 All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"bytes"
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"time"
)
func TestCreateOpenIDClient(t *testing.T) {
_, auth, _ := newTestProxyService(nil)
client, _, err := createOpenIDClient(&Config{
DiscoveryURL: auth.location.String() + "/auth/realms/hod-test",
})
assert.NoError(t, err)
assert.NotNil(t, client)
}
func TestDecodeKeyPairs(t *testing.T) {
testCases := []struct {
List []string
KeyPairs map[string]string
Ok bool
}{
{
List: []string{"a=b", "b=3"},
KeyPairs: map[string]string{
"a": "b",
"b": "3",
},
Ok: true,
},
{
List: []string{"add", "b=3"},
},
}
for i, c := range testCases {
kp, err := decodeKeyPairs(c.List)
if err != nil && c.Ok {
t.Errorf("test case %d should not have failed", i)
continue
}
if !c.Ok {
continue
}
if !reflect.DeepEqual(kp, c.KeyPairs) {