| 1 |
// Copyright (c) 2016 VMware, Inc. All Rights Reserved. |
| 2 |
// |
| 3 |
// This product is licensed to you under the Apache License, Version 2.0 (the "License"). |
| 4 |
// You may not use this product except in compliance with the License. |
| 5 |
// |
| 6 |
// This product may include a number of subcomponents with separate copyright notices and |
| 7 |
// license terms. Your use of these subcomponents is subject to the terms and conditions |
| 8 |
// of the subcomponent's license, as noted in the LICENSE file. |
| 9 |
|
| 10 |
package lightwave |
| 11 |
|
| 12 |
import ( |
| 13 |
"os" |
| 14 |
"testing" |
| 15 |
|
| 16 |
. "github.com/onsi/ginkgo" |
| 17 |
. "github.com/onsi/gomega" |
| 18 |
|
| 19 |
"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks" |
| 20 |
) |
| 21 |
|
| 22 |
func TestPhotonLightWave(t *testing.T) { |
| 23 |
RegisterFailHandler(Fail) |
| 24 |
RunSpecs(t, "Go SDK LightWave Suite") |
| 25 |
} |
| 26 |
|
| 27 |
func testSetupFakeServer() (client *OIDCClient, server *mocks.Server) { |
| 28 |
server = mocks.NewTlsTestServer() |
| 29 |
|
| 30 |
options := &OIDCClientOptions{ |
| 31 |
IgnoreCertificate: true, |
| 32 |
} |
| 33 |
|
| 34 |
client = NewOIDCClient(server.HttpServer.URL, options, nil) |
| 35 |
return |
| 36 |
} |
| 37 |
|
| 38 |
func testSetupRealServer(options *OIDCClientOptions) (client *OIDCClient, username string, password string) { |
| 39 |
// If LIGHTWAVE_ENDPOINT env var is set, return an empty server and point |
| 40 |
// the client to LIGHTWAVE_ENDPOINT. This lets us run tests as integration tests |
| 41 |
if len(os.Getenv("LIGHTWAVE_ENDPOINT")) == 0 { |
| 42 |
return |
| 43 |
} |
| 44 |
|
| 45 |
client = NewOIDCClient(os.Getenv("LIGHTWAVE_ENDPOINT"), options, nil) |
| 46 |
username = os.Getenv("LIGHTWAVE_USERNAME") |
| 47 |
password = os.Getenv("LIGHTWAVE_PASSWORD") |
| 48 |
return |
| 49 |
} |