@@ -28,46 +28,66 @@ public void GitHubHostProvider_IsGitHubDotCom(string input, bool expected)
28
28
[ Theory ]
29
29
// We report that we support unencrypted HTTP here so that we can fail and
30
30
// show a helpful error message in the call to `GenerateCredentialAsync` instead.
31
- [ InlineData ( "http://github.com" , true ) ]
32
- [ InlineData ( "http://gist.github.com" , true ) ]
33
- [ InlineData ( "https://github.com" , true ) ]
34
- [ InlineData ( "https://gist.github.com" , true ) ]
35
- [ InlineData ( "ssh://github.com" , false ) ]
36
- [ InlineData ( "https://example.com" , false ) ]
37
- public void GitHubHostProvider_IsSupported ( string uriString , bool expected )
31
+ [ InlineData ( "http" , "github.com" , true ) ]
32
+ [ InlineData ( "http" , "gist.github.com" , true ) ]
33
+ [ InlineData ( "ssh" , "github.com" , false ) ]
34
+ [ InlineData ( "https" , "example.com" , false ) ]
35
+
36
+ [ InlineData ( "https" , "github.com" , true ) ]
37
+ [ InlineData ( "https" , "github.con" , false ) ] // No support of phony similar tld.
38
+ [ InlineData ( "https" , "gist.github.con" , false ) ] // No support of phony similar tld.
39
+ [ InlineData ( "https" , "foogithub.jparrowsec.cn" , false ) ] // No support of non github.com domains.
40
+ [ InlineData ( "https" , "api.github.com" , false ) ] // No support of github.com subdomains.
41
+ [ InlineData ( "https" , "gist.github.com" , true ) ] // Except gists.
42
+ [ InlineData ( "https" , "GiST.github.com" , true ) ]
43
+ [ InlineData ( "https" , "github.com" , true ) ]
44
+
45
+ [ InlineData ( "http" , "github.my-company-server.com" , true ) ]
46
+ [ InlineData ( "http" , "gist.github.my-company-server.com" , true ) ]
47
+ [ InlineData ( "https" , "github.my-company-server.com" , true ) ]
48
+ [ InlineData ( "https" , "gist.github.my-company-server.com" , true ) ]
49
+ [ InlineData ( "https" , "gist.my-company-server.com" , false ) ]
50
+ [ InlineData ( "https" , "my-company-server.com" , false ) ]
51
+ [ InlineData ( "https" , "github.my.company.server.com" , true ) ]
52
+ [ InlineData ( "https" , "foogithub.my-company-server.com" , false ) ]
53
+ [ InlineData ( "https" , "api.github.my-company-server.com" , false ) ]
54
+ [ InlineData ( "https" , "gist.github.my.company.server.com" , true ) ]
55
+ [ InlineData ( "https" , "GitHub.My-Company-Server.Com" , true ) ]
56
+ [ InlineData ( "https" , "GiST.GitHub.My-Company-Server.com" , true ) ]
57
+ public void GitHubHostProvider_IsSupported ( string protocol , string host , bool expected )
38
58
{
39
- Uri uri = new Uri ( uriString ) ;
40
-
41
59
var input = new InputArguments ( new Dictionary < string , string >
42
60
{
43
- [ "protocol" ] = uri . Scheme ,
44
- [ "host" ] = uri . Host ,
61
+ [ "protocol" ] = protocol ,
62
+ [ "host" ] = host ,
45
63
} ) ;
46
64
47
- // Ensure nothing got lost during transformation
48
- Assert . Equal ( uriString , input . Protocol + "://" + input . Host ) ;
49
-
50
65
var provider = new GitHubHostProvider ( new TestCommandContext ( ) ) ;
51
66
Assert . Equal ( expected , provider . IsSupported ( input ) ) ;
52
67
}
53
68
54
69
55
70
[ Theory ]
56
- [ InlineData ( "https://github.com" , "https://github.com" ) ]
57
- [ InlineData ( "https://gist.github.com" , "https://github.com" ) ]
58
- public void GitHubHostProvider_GetCredentialServiceUrl ( string uriString , string expectedService )
71
+ [ InlineData ( "https" , "github.com" , "https://github.com" ) ]
72
+ [ InlineData ( "https" , "github.com" , "https://github.com" ) ]
73
+ [ InlineData ( "https" , "gist.github.com" , "https://github.com" ) ]
74
+ [ InlineData ( "https" , "GiST.github.com" , "https://github.com" ) ]
75
+ [ InlineData ( "https" , "github.my-company-server.com" , "https://github.my-company-server.com" ) ]
76
+ [ InlineData ( "https" , "GitHub.My-Company-Server.Com" , "https://github.my-company-server.com" ) ]
77
+ [ InlineData ( "https" , "gist.github.my-company-server.com" , "https://github.my-company-server.com" ) ]
78
+ [ InlineData ( "https" , "GiST.GitHub.My-Company-Server.Com" , "https://github.my-company-server.com" ) ]
79
+ [ InlineData ( "https" , "github.my.company.server.com" , "https://github.my.company.server.com" ) ]
80
+ [ InlineData ( "https" , "GitHub.My.Company.Server.Com" , "https://github.my.company.server.com" ) ]
81
+ [ InlineData ( "https" , "gist.github.my.company.server.com" , "https://github.my.company.server.com" ) ]
82
+ [ InlineData ( "https" , "GiST.GitHub.My.Company.Server.Com" , "https://github.my.company.server.com" ) ]
83
+ public void GitHubHostProvider_GetCredentialServiceUrl ( string protocol , string host , string expectedService )
59
84
{
60
- Uri uri = new Uri ( uriString ) ;
61
-
62
85
var input = new InputArguments ( new Dictionary < string , string >
63
86
{
64
- [ "protocol" ] = uri . Scheme ,
65
- [ "host" ] = uri . Host ,
87
+ [ "protocol" ] = protocol ,
88
+ [ "host" ] = host ,
66
89
} ) ;
67
90
68
- // Ensure nothing got lost during transformation
69
- Assert . Equal ( uriString , input . Protocol + "://" + input . Host ) ;
70
-
71
91
var provider = new GitHubHostProvider ( new TestCommandContext ( ) ) ;
72
92
Assert . Equal ( expectedService , provider . GetServiceName ( input ) ) ;
73
93
}
@@ -76,8 +96,11 @@ public void GitHubHostProvider_GetCredentialServiceUrl(string uriString, string
76
96
[ Theory ]
77
97
[ InlineData ( "https://example.com" , "oauth" , AuthenticationModes . OAuth ) ]
78
98
[ InlineData ( "https://github.com" , "NOT-A-REAL-VALUE" , GitHubConstants . DotComAuthenticationModes ) ]
99
+ [ InlineData ( "https://github.com" , "NOT-A-REAL-VALUE" , GitHubConstants . DotComAuthenticationModes ) ]
79
100
[ InlineData ( "https://github.com" , "none" , GitHubConstants . DotComAuthenticationModes ) ]
101
+ [ InlineData ( "https://github.com" , "none" , GitHubConstants . DotComAuthenticationModes ) ]
80
102
[ InlineData ( "https://github.com" , null , GitHubConstants . DotComAuthenticationModes ) ]
103
+ [ InlineData ( "https://github.com" , null , GitHubConstants . DotComAuthenticationModes ) ]
81
104
public async Task GitHubHostProvider_GetSupportedAuthenticationModes ( string uriString , string gitHubAuthModes , AuthenticationModes expectedModes )
82
105
{
83
106
var targetUri = new Uri ( uriString ) ;
0 commit comments