2015-08-26 20:42:02 -04:00
|
|
|
// Copyright 2014 The Go Authors. All rights reserved.
|
2015-01-16 17:43:33 -05:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Package internal contains support packages for oauth2 package.
|
|
|
|
package internal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2015-11-16 16:49:40 -05:00
|
|
|
func TestRegisterBrokenAuthHeaderProvider(t *testing.T) {
|
|
|
|
RegisterBrokenAuthHeaderProvider("https://aaa.com/")
|
|
|
|
tokenURL := "https://aaa.com/token"
|
|
|
|
if providerAuthHeaderWorks(tokenURL) {
|
2016-08-26 14:51:24 -04:00
|
|
|
t.Errorf("got %q as unbroken; want broken", tokenURL)
|
2015-11-16 16:49:40 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-16 17:43:33 -05:00
|
|
|
func Test_providerAuthHeaderWorks(t *testing.T) {
|
|
|
|
for _, p := range brokenAuthHeaderProviders {
|
|
|
|
if providerAuthHeaderWorks(p) {
|
2016-08-26 14:51:24 -04:00
|
|
|
t.Errorf("got %q as unbroken; want broken", p)
|
2015-01-16 17:43:33 -05:00
|
|
|
}
|
|
|
|
p := fmt.Sprintf("%ssomesuffix", p)
|
|
|
|
if providerAuthHeaderWorks(p) {
|
2016-08-26 14:51:24 -04:00
|
|
|
t.Errorf("got %q as unbroken; want broken", p)
|
2015-01-16 17:43:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
p := "https://api.not-in-the-list-example.com/"
|
|
|
|
if !providerAuthHeaderWorks(p) {
|
2016-08-26 14:51:24 -04:00
|
|
|
t.Errorf("got %q as unbroken; want broken", p)
|
2015-01-16 17:43:33 -05:00
|
|
|
}
|
|
|
|
}
|