Skip to content

Commit

Permalink
Added support for CP-member (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
AjeyHiremath authored and jkraj committed Mar 26, 2018
1 parent 8d79560 commit eb59361
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import (
"encoding/json"
"errors"
"fmt"
"golang.org/x/net/publicsuffix"
"io/ioutil"
"log"
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
"time"

"golang.org/x/net/publicsuffix"
)

type HostConfig struct {
Expand Down Expand Up @@ -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()
}

Expand Down
10 changes: 6 additions & 4 deletions connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
})
Expand Down

0 comments on commit eb59361

Please sign in to comment.