-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcredentials_test.go
67 lines (58 loc) · 1.4 KB
/
credentials_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package oauth1
import (
"fmt"
"net/url"
"reflect"
"testing"
)
func TestCallback(t *testing.T) {
testCases := []struct {
name string
callback *url.URL
want string
}{
{
"no previous query",
mustParseURL("http://foo.example.com"),
"http://foo.example.com?oauth_token=foo&oauth_verifier=slash%2Fslash",
},
{
"append to query",
mustParseURL("http://foo.example.com?xxx=888"),
"http://foo.example.com?xxx=888&oauth_token=foo&oauth_verifier=slash%2Fslash",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
tkn := &TempCredentials{
ID: "foo",
Secret: "bar",
ClientID: "baz",
Callback: tc.callback,
VerificationCode: "slash/slash",
}
url := tkn.verifiedCallback()
if url != tc.want {
t.Errorf("want %s, got %s", tc.want, url)
}
})
}
}
func (c *ClientCredentials) String() string {
return fmt.Sprintf("<client %v>", c.ID)
}
func (c *ClientCredentials) is(cc *ClientCredentials) bool {
return reflect.DeepEqual(c, cc)
}
func (t *TokenCredentials) String() string {
return fmt.Sprintf("<token %v>", t.ID)
}
func (t *TokenCredentials) is(tt *TokenCredentials) bool {
return reflect.DeepEqual(t, tt)
}
func (t *TempCredentials) String() string {
return fmt.Sprintf("<temp %v>", t.ID)
}
func (t *TempCredentials) is(tt *TempCredentials) bool {
return reflect.DeepEqual(t, tt)
}