File: main_test.go

package info (click to toggle)
git-credential-oauth 0.15.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 152 kB
  • sloc: makefile: 7
file content (35 lines) | stat: -rw-r--r-- 823 bytes parent folder | download | duplicates (2)
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
package main

import (
	"strings"
	"testing"
)

func TestConfig(t *testing.T) {
	for key, c := range configByHost {
		if key == "android.googlesource.com" {
			continue
		}
		if !strings.Contains(c.Endpoint.AuthURL, key) {
			t.Errorf("bad auth url for key %s: %s", key, c.Endpoint.AuthURL)
		}
		if !strings.Contains(c.Endpoint.TokenURL, key) {
			t.Errorf("bad token url for key %s: %s", key, c.Endpoint.TokenURL)
		}
		if c.Endpoint.DeviceAuthURL != "" && !strings.Contains(c.Endpoint.DeviceAuthURL, key) {
			t.Errorf("bad device auth url for key %s: %s", key, c.Endpoint.DeviceAuthURL)
		}
	}
}

func FuzzParse(f *testing.F) {
	f.Add("key=value")
	f.Add("key=")
	f.Add("==")
	f.Add("\n\n\n")
	f.Add("key=value=long")
	f.Add("wwwauth[]=value1\nwwwauth[]=value2")
	f.Fuzz(func(_ *testing.T, s string) {
		parse(s)
	})
}