Skip to content

Commit

Permalink
fix gofmt and goimports issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bbiao committed Sep 24, 2019
1 parent 71c4d43 commit 87e080a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion logout_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ func TestParseLogoutRequestWithISO8601(t *testing.T) {
t.Errorf("Expected IssueInstant to be <%v>, got <%v>",
instant, l.IssueInstant)
}
}
}
12 changes: 6 additions & 6 deletions rest_client.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package cas

import (
"net/url"
"net/http"
"github.com/golang/glog"
"fmt"
"path"
"io/ioutil"
"net/http"
"net/url"
"path"

"github.com/golang/glog"
)

// https://apereo.github.io/cas/4.2.x/protocol/REST-Protocol.html
Expand All @@ -17,7 +18,6 @@ type TicketGrantingTicket string
// ServiceTicket stands for the access granted by the CAS server to an application for a specific user, also known as ST
type ServiceTicket string


// RestOptions provide options for the RestClient
type RestOptions struct {
CasURL *url.URL
Expand Down Expand Up @@ -175,4 +175,4 @@ func (c *RestClient) Logout(tgt TicketGrantingTicket) error {
}

return nil
}
}
15 changes: 7 additions & 8 deletions rest_client_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package cas

import (
"testing"
"net/http/httptest"
"net/http"
"net/http/httptest"
"net/url"
"testing"
)

func TestRequestGrantingTicket(t *testing.T) {
Expand Down Expand Up @@ -81,16 +81,15 @@ func TestRequestServiceTicket(t *testing.T) {
t.Error("failed to create cas url from test server")
}


serviceURL, err := url.Parse("https://hitchhiker.com/heartOfGold")
if err != nil {
t.Error("failed to create service url")
}

restClient := NewRestClient(&RestOptions{
CasURL: casURL,
CasURL: casURL,
ServiceURL: serviceURL,
Client: server.Client(),
Client: server.Client(),
})

st, err := restClient.RequestServiceTicket(TicketGrantingTicket("TGT-abc"))
Expand All @@ -113,9 +112,9 @@ func TestRequestServiceTicket(t *testing.T) {
}

restClient = NewRestClient(&RestOptions{
CasURL: casURL,
CasURL: casURL,
ServiceURL: serviceURL,
Client: server.Client(),
Client: server.Client(),
})

_, err = restClient.RequestServiceTicket(TicketGrantingTicket("TGT-abc"))
Expand Down Expand Up @@ -186,4 +185,4 @@ func TestLogout(t *testing.T) {
if err == nil {
t.Errorf("logout should failed for this TGT")
}
}
}
16 changes: 8 additions & 8 deletions url_scheme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ func TestDefaultURLScheme(t *testing.T) {
scheme := NewDefaultURLScheme(url)

u, err := scheme.Login()
assertUrl(t, "/cas/login", u, err)
assertURL(t, "/cas/login", u, err)
u, err = scheme.Logout()
assertUrl(t, "/cas/logout", u, err)
assertURL(t, "/cas/logout", u, err)
u, err = scheme.Validate()
assertUrl(t, "/cas/validate", u, err)
assertURL(t, "/cas/validate", u, err)
u, err = scheme.ServiceValidate()
assertUrl(t, "/cas/serviceValidate", u, err)
assertURL(t, "/cas/serviceValidate", u, err)
u, err = scheme.RestGrantingTicket()
assertUrl(t, "/cas/v1/tickets", u, err)
assertURL(t, "/cas/v1/tickets", u, err)
u, err = scheme.RestServiceTicket("TGT-123")
assertUrl(t, "/cas/v1/tickets/TGT-123", u, err)
assertURL(t, "/cas/v1/tickets/TGT-123", u, err)
u, err = scheme.RestLogout("TGT-123")
assertUrl(t, "/cas/v1/tickets/TGT-123", u, err)
assertURL(t, "/cas/v1/tickets/TGT-123", u, err)
}

func assertUrl(t *testing.T, expected string, u *url.URL, err error) {
func assertURL(t *testing.T, expected string, u *url.URL, err error) {
if err != nil {
t.Fatalf("returned error")
}
Expand Down

0 comments on commit 87e080a

Please sign in to comment.