auth

Paddy 2014-07-18

0:7a6f64db7246 Go to Latest

auth/info_test.go

Start rewriting the repo. This code originally was a carbon copy of https://github.com/RangelReale/osin, but I am methodically stripping out the extensible nature of it for a simpler interface, while simultaneously bringing the style into line with the Ducky style.

History
1 package oauth2
3 import (
4 "net/http"
5 "net/url"
6 "testing"
7 )
9 func TestInfo(t *testing.T) {
10 sconfig := NewServerConfig()
11 server := NewServer(sconfig, NewTestingStorage())
12 resp := server.NewResponse()
14 req, err := http.NewRequest("GET", "http://localhost:14000/appauth", nil)
15 if err != nil {
16 t.Fatal(err)
17 }
18 req.Form = make(url.Values)
19 req.Form.Set("code", "9999")
21 if ar := server.HandleInfoRequest(resp, req); ar != nil {
22 server.FinishInfoRequest(resp, req, ar)
23 }
25 //fmt.Printf("%+v", resp)
27 if resp.IsError && resp.InternalError != nil {
28 t.Fatalf("Error in response: %s", resp.InternalError)
29 }
31 if resp.IsError {
32 t.Fatalf("Should not be an error")
33 }
35 if resp.Type != DATA {
36 t.Fatalf("Response should be data")
37 }
39 if d := resp.Output["access_token"]; d != "9999" {
40 t.Fatalf("Unexpected authorization code: %s", d)
41 }
42 }