diff options
author | Frédéric Guillot <fred@miniflux.net> | 2017-11-22 22:22:33 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2017-11-22 22:22:33 -0800 |
commit | cc6d272eb7719bcca02c7f36a1badbeecb153759 (patch) | |
tree | 2fd6e92dcaa19faccfc25ff67499abcc6dabbaaf /vendor/golang.org/x/oauth2/google/sdk_test.go | |
parent | 9877051f12621aa71daad520caa2847c47c746f8 (diff) |
Add OAuth2 authentication
Diffstat (limited to 'vendor/golang.org/x/oauth2/google/sdk_test.go')
-rw-r--r-- | vendor/golang.org/x/oauth2/google/sdk_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/vendor/golang.org/x/oauth2/google/sdk_test.go b/vendor/golang.org/x/oauth2/google/sdk_test.go new file mode 100644 index 0000000..4489bb9 --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/sdk_test.go @@ -0,0 +1,46 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package google + +import "testing" + +func TestSDKConfig(t *testing.T) { + sdkConfigPath = func() (string, error) { + return "testdata/gcloud", nil + } + + tests := []struct { + account string + accessToken string + err bool + }{ + {"", "bar_access_token", false}, + {"foo@example.com", "foo_access_token", false}, + {"bar@example.com", "bar_access_token", false}, + {"baz@serviceaccount.example.com", "", true}, + } + for _, tt := range tests { + c, err := NewSDKConfig(tt.account) + if got, want := err != nil, tt.err; got != want { + if !tt.err { + t.Errorf("got %v, want nil", err) + } else { + t.Errorf("got nil, want error") + } + continue + } + if err != nil { + continue + } + tok := c.initialToken + if tok == nil { + t.Errorf("got nil, want %q", tt.accessToken) + continue + } + if tok.AccessToken != tt.accessToken { + t.Errorf("got %q, want %q", tok.AccessToken, tt.accessToken) + } + } +} |