From eb593614d9cd27423fcb69deac7371a95363318a Mon Sep 17 00:00:00 2001 From: Ajey Hiremath <33475681+AjeyHiremath@users.noreply.github.com> Date: Mon, 26 Mar 2018 17:08:33 +0530 Subject: [PATCH] Added support for CP-member (#50) --- connector.go | 5 ++++- connector_test.go | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/connector.go b/connector.go index e5c82b89..3c395618 100644 --- a/connector.go +++ b/connector.go @@ -7,7 +7,6 @@ import ( "encoding/json" "errors" "fmt" - "golang.org/x/net/publicsuffix" "io/ioutil" "log" "net/http" @@ -15,6 +14,8 @@ import ( "net/url" "strings" "time" + + "golang.org/x/net/publicsuffix" ) type HostConfig struct { @@ -180,6 +181,8 @@ func (wrb *WapiRequestBuilder) BuildUrl(t RequestType, objType string, ref strin if len(returnFields) > 0 { vals.Set("_return_fields", strings.Join(returnFields, ",")) } + // TODO need to get this from individual objects in future + vals.Set("_proxy_search", "GM") qry = vals.Encode() } diff --git a/connector_test.go b/connector_test.go index 87910e91..d788aea1 100644 --- a/connector_test.go +++ b/connector_test.go @@ -4,11 +4,12 @@ import ( "bytes" "encoding/json" "fmt" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" "net/http" "net/url" "strings" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" ) type FakeRequestBuilder struct { @@ -100,11 +101,12 @@ var _ = Describe("Connector", func() { It("should return expected url string for GET for the return fields", func() { objType := "network" ref := "" + qry := "_proxy_search=GM" returnFields := []string{"extattrs", "network", "network_view"} returnFieldsStr := "_return_fields" + "=" + url.QueryEscape(strings.Join(returnFields, ",")) - expectedURLStr := fmt.Sprintf("https://%s:%s/wapi/v%s/%s?%s", - host, port, version, objType, returnFieldsStr) + expectedURLStr := fmt.Sprintf("https://%s:%s/wapi/v%s/%s?%s&%s", + host, port, version, objType, qry, returnFieldsStr) urlStr := wrb.BuildUrl(GET, objType, ref, returnFields) Expect(urlStr).To(Equal(expectedURLStr)) })