-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathauth_google_test.go
More file actions
55 lines (50 loc) · 1.25 KB
/
auth_google_test.go
File metadata and controls
55 lines (50 loc) · 1.25 KB
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
package titan
import (
"encoding/json"
"testing"
)
// Response from: GET https://www.googleapis.com/plus/v1/people/me?access_token=...
// (retrieved on 5th of July, 2015)
var googleAuthResStr = []byte(`{
"kind": "plus#person",
"etag": "\"abcd123\"",
"gender": "male",
"emails": [
{
"value": "chuck@titan.com",
"type": "account"
}
],
"objectType": "person",
"id": "1234567890",
"displayName": "Chuck Norris",
"name": {
"familyName": "Chuck",
"givenName": "Norris"
},
"url": "https://plus.google.com/1234567890",
"image": {
"url": "https://lh3.googleusercontent.com/asdfgsgdsfs/afsdggg/sdafdsff/1234dfgg/photo.jpg?sz=50",
"isDefault": false
},
"isPlusUser": true,
"language": "en",
"circledByCount": 999,
"verified": false
}`)
var (
displayName = "Chuck Norris"
email = "chuck@titan.com"
imgURL = "https://lh3.googleusercontent.com/asdfgsgdsfs/afsdggg/sdafdsff/1234dfgg/photo.jpg?sz=50"
)
func TestGoogleAuth(t *testing.T) {
var profile gPlusProfile
if err := json.Unmarshal(googleAuthResStr, &profile); err != nil {
t.Fatal(err)
}
if profile.DisplayName != displayName ||
profile.Emails[0].Value != email ||
profile.Image.URL != imgURL {
t.Fatal("Cannot deserialize Google 'plus/v1/people/me' response.")
}
}