auth

Paddy 2014-11-02 Parent:b3cd7765a7c8 Child:dd5d23d490ee

60:0cc717e02c9b Go to Latest

auth/http_test.go

Fill out redirects. Actually redirect the user when obtaining a grant. Check if the redirect_uri being passed when obtaining a grant is _actually a URL_. If it's not, return the right error. Add a test for a redirect_uri that isn't a valid URL.

History
     1.1 --- a/http_test.go	Sun Oct 26 03:31:24 2014 -0400
     1.2 +++ b/http_test.go	Sun Nov 02 20:45:51 2014 -0500
     1.3 @@ -136,4 +136,18 @@
     1.4  	if w.Body.String() != "The redirect_uri specified is not valid." {
     1.5  		t.Errorf(`Expected output to be "%s", got "%s" instead.`, "The redirect_uri specified is not valid.", w.Body.String())
     1.6  	}
     1.7 +	req, err = http.NewRequest("GET", "https://test.auth.secondbit.org/oauth2/grant", nil)
     1.8 +	if err != nil {
     1.9 +		t.Fatal("Can't build request:", err)
    1.10 +	}
    1.11 +	w = httptest.NewRecorder()
    1.12 +	params.Set("redirect_uri", "not a URL")
    1.13 +	req.URL.RawQuery = params.Encode()
    1.14 +	GetGrantHandler(w, req, testContext)
    1.15 +	if w.Code != http.StatusBadRequest {
    1.16 +		t.Errorf("Expected status code to be %d, got %d", http.StatusBadRequest, w.Code)
    1.17 +	}
    1.18 +	if w.Body.String() != "The redirect_uri specified is not valid." {
    1.19 +		t.Errorf(`Expected output to be "%s", got "%s" instead.`, "The redirect_uri specified is not valid.", w.Body.String())
    1.20 +	}
    1.21  }