You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
name: "token for github.com with no env tokens and no config token",
25
-
host: "github.com",
26
-
config: testNoHostsConfig(),
27
-
wantToken: "",
28
-
wantSource: "oauth_token",
29
-
wantNotFound: true,
24
+
name: "given there is no env token and no config token, when we get the token for github.com, then it returns the empty string and default source",
25
+
host: "github.com",
26
+
config: testNoHostsConfig(),
27
+
wantToken: "",
28
+
wantSource: defaultSource,
30
29
},
31
30
{
32
-
name: "token for enterprise.com with no env tokens and no config token",
33
-
host: "enterprise.com",
34
-
config: testNoHostsConfig(),
35
-
wantToken: "",
36
-
wantSource: "oauth_token",
37
-
wantNotFound: true,
31
+
name: "given there is no env token and no config token, when we get the token for an enterprise server host, then it returns the empty string and default source",
32
+
host: "enterprise.com",
33
+
config: testNoHostsConfig(),
34
+
wantToken: "",
35
+
wantSource: defaultSource,
38
36
},
39
37
{
40
-
name: "token for github.com with GH_TOKEN, GITHUB_TOKEN, and config token",
38
+
name: "given GH_TOKEN and GITHUB_TOKEN and a config token are set, when we get the token for github.com, then it returns GH_TOKEN as the priority",
41
39
host: "github.com",
42
40
ghToken: "GH_TOKEN",
43
41
githubToken: "GITHUB_TOKEN",
44
42
config: testHostsConfig(),
45
43
wantToken: "GH_TOKEN",
46
-
wantSource: "GH_TOKEN",
44
+
wantSource: ghToken,
47
45
},
48
46
{
49
-
name: "token for github.com with GITHUB_TOKEN, and config token",
47
+
name: "given GITHUB_TOKEN and a config token are set, when we get the token for github.com, then it returns GITHUB_TOKEN as the priority",
50
48
host: "github.com",
51
49
githubToken: "GITHUB_TOKEN",
52
50
config: testHostsConfig(),
53
51
wantToken: "GITHUB_TOKEN",
54
-
wantSource: "GITHUB_TOKEN",
52
+
wantSource: githubToken,
55
53
},
56
54
{
57
-
name: "token for github.com with config token",
55
+
name: "given a config token is set for github.com, when we get the token, then it returns that token and oauth_token source",
58
56
host: "github.com",
59
57
config: testHostsConfig(),
60
58
wantToken: "xxxxxxxxxxxxxxxxxxxx",
61
-
wantSource: "oauth_token",
59
+
wantSource: oauthToken,
60
+
},
61
+
{
62
+
name: "given GH_TOKEN and GITHUB_TOKEN and a config token are set, when we get the token for any subdomain of ghe.com, then it returns GH_TOKEN as the priority",
63
+
host: "tenant.ghe.com",
64
+
ghToken: "GH_TOKEN",
65
+
githubToken: "GITHUB_TOKEN",
66
+
config: testHostsConfig(),
67
+
wantToken: "GH_TOKEN",
68
+
wantSource: ghToken,
69
+
},
70
+
{
71
+
name: "given GITHUB_TOKEN and a config token are set, when we get the token for any subdomain of ghe.com, then it returns GITHUB_TOKEN as the priority",
72
+
host: "tenant.ghe.com",
73
+
githubToken: "GITHUB_TOKEN",
74
+
config: testHostsConfig(),
75
+
wantToken: "GITHUB_TOKEN",
76
+
wantSource: githubToken,
77
+
},
78
+
{
79
+
name: "given a config token is set for a subdomain of ghe.com, when we get the token for that subdomain, then it returns that token and oauth_token source",
80
+
host: "tenant.ghe.com",
81
+
config: testHostsConfig(),
82
+
wantToken: "zzzzzzzzzzzzzzzzzzzz",
83
+
wantSource: oauthToken,
84
+
},
85
+
{
86
+
name: "given GH_TOKEN and GITHUB_TOKEN and a config token are set, when we get the token for github.localhost, then it returns GH_TOKEN as the priority",
87
+
host: "github.localhost",
88
+
ghToken: "GH_TOKEN",
89
+
githubToken: "GITHUB_TOKEN",
90
+
config: testHostsConfig(),
91
+
wantToken: "GH_TOKEN",
92
+
wantSource: ghToken,
62
93
},
63
94
{
64
-
name: "token for enterprise.com with GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN, and config token",
95
+
name: "given GITHUB_TOKEN and a config token are set, when we get the token for any subdomain of github.localhost, then it returns GITHUB_TOKEN as the priority",
96
+
host: "github.localhost",
97
+
githubToken: "GITHUB_TOKEN",
98
+
config: testHostsConfig(),
99
+
wantToken: "GITHUB_TOKEN",
100
+
wantSource: githubToken,
101
+
},
102
+
{
103
+
name: "given GH_ENTERPRISE_TOKEN and GITHUB_ENTERPRISE_TOKEN and a config token are set, when we get the token for an enterprise server host, then it returns GH_ENTERPRISE_TOKEN as the priority",
65
104
host: "enterprise.com",
66
105
ghEnterpriseToken: "GH_ENTERPRISE_TOKEN",
67
106
githubEnterpriseToken: "GITHUB_ENTERPRISE_TOKEN",
68
107
config: testHostsConfig(),
69
108
wantToken: "GH_ENTERPRISE_TOKEN",
70
-
wantSource: "GH_ENTERPRISE_TOKEN",
109
+
wantSource: ghEnterpriseToken,
71
110
},
72
111
{
73
-
name: "token for enterprise.com with GITHUB_ENTERPRISE_TOKEN, and config token",
112
+
name: "given GITHUB_ENTERPRISE_TOKEN and a config token are set, when we get the token for an enterprise server host, then it returns GITHUB_ENTERPRISE_TOKEN as the priority",
74
113
host: "enterprise.com",
75
114
githubEnterpriseToken: "GITHUB_ENTERPRISE_TOKEN",
76
115
config: testHostsConfig(),
77
116
wantToken: "GITHUB_ENTERPRISE_TOKEN",
78
-
wantSource: "GITHUB_ENTERPRISE_TOKEN",
117
+
wantSource: githubEnterpriseToken,
79
118
},
80
119
{
81
-
name: "token for enterprise.com with config token",
120
+
name: "given a config token is set for an enterprise server host, when we get the token for that host, then it returns that token and oauth_token source",
82
121
host: "enterprise.com",
83
122
config: testHostsConfig(),
84
123
wantToken: "yyyyyyyyyyyyyyyyyyyy",
85
-
wantSource: "oauth_token",
124
+
wantSource: oauthToken,
86
125
},
87
126
{
88
-
name: "token for tenant with GH_TOKEN, GITHUB_TOKEN, and config token",
89
-
host: "tenant.ghe.com",
127
+
name: "given GH_TOKEN or GITHUB_TOKEN are set, when I get the token for any host not owned by GitHub, we do not get those tokens",
128
+
host: "unknown.com",
129
+
config: testNoHostsConfig(),
90
130
ghToken: "GH_TOKEN",
91
131
githubToken: "GITHUB_TOKEN",
92
-
config: testHostsConfig(),
93
-
wantToken: "GH_TOKEN",
94
-
wantSource: "GH_TOKEN",
95
-
},
96
-
{
97
-
name: "token for tenant with GITHUB_TOKEN, and config token",
0 commit comments