token_test.go 952 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Package internal contains support packages for oauth2 package.
  5. package internal
  6. import (
  7. "fmt"
  8. "testing"
  9. )
  10. func TestRegisterBrokenAuthHeaderProvider(t *testing.T) {
  11. RegisterBrokenAuthHeaderProvider("https://aaa.com/")
  12. tokenURL := "https://aaa.com/token"
  13. if providerAuthHeaderWorks(tokenURL) {
  14. t.Errorf("URL: %s is a broken provider", tokenURL)
  15. }
  16. }
  17. func Test_providerAuthHeaderWorks(t *testing.T) {
  18. for _, p := range brokenAuthHeaderProviders {
  19. if providerAuthHeaderWorks(p) {
  20. t.Errorf("URL: %s not found in list", p)
  21. }
  22. p := fmt.Sprintf("%ssomesuffix", p)
  23. if providerAuthHeaderWorks(p) {
  24. t.Errorf("URL: %s not found in list", p)
  25. }
  26. }
  27. p := "https://api.not-in-the-list-example.com/"
  28. if !providerAuthHeaderWorks(p) {
  29. t.Errorf("URL: %s found in list", p)
  30. }
  31. }