Skip to content

Commit b9c3f41

Browse files
committed
bitbucket: add tests for IsBitbucketOrg method
Add test for Bitbucket Cloud hostname detection method.
1 parent bb94c4f commit b9c3f41

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

src/shared/Atlassian.Bitbucket.Tests/BitbucketHostProviderTest.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,58 @@ public class BitbucketHostProviderTest
2121
private Mock<IBitbucketAuthentication> bitbucketAuthentication = new Mock<IBitbucketAuthentication>(MockBehavior.Strict);
2222
private Mock<IBitbucketRestApi> bitbucketApi = new Mock<IBitbucketRestApi>(MockBehavior.Strict);
2323

24+
[Theory]
25+
[InlineData(null, false)]
26+
[InlineData("", false)]
27+
[InlineData(" ", false)]
28+
[InlineData("bitbucket.org", true)]
29+
[InlineData("BITBUCKET.ORG", true)]
30+
[InlineData("BiTbUcKeT.OrG", true)]
31+
[InlineData("bitbucket.example.com", false)]
32+
[InlineData("bitbucket.example.org", false)]
33+
[InlineData("bitbucket.org.com", false)]
34+
[InlineData("bitbucket.org.org", false)]
35+
public void BitbucketHostProvider_IsBitbucketOrg_StringHost(string str, bool expected)
36+
{
37+
bool actual = BitbucketHostProvider.IsBitbucketOrg(str);
38+
Assert.Equal(expected, actual);
39+
}
40+
41+
[Theory]
42+
[InlineData("http://bitbucket.org", true)]
43+
[InlineData("https://bitbucket.org", true)]
44+
[InlineData("http://bitbucket.org/path", true)]
45+
[InlineData("https://bitbucket.org/path", true)]
46+
[InlineData("http://BITBUCKET.ORG", true)]
47+
[InlineData("https://BITBUCKET.ORG", true)]
48+
[InlineData("http://BITBUCKET.ORG/PATH", true)]
49+
[InlineData("https://BITBUCKET.ORG/PATH", true)]
50+
[InlineData("http://BiTbUcKeT.OrG", true)]
51+
[InlineData("https://BiTbUcKeT.OrG", true)]
52+
[InlineData("http://BiTbUcKeT.OrG/pAtH", true)]
53+
[InlineData("https://BiTbUcKeT.OrG/pAtH", true)]
54+
[InlineData("http://bitbucket.example.com", false)]
55+
[InlineData("https://bitbucket.example.com", false)]
56+
[InlineData("http://bitbucket.example.com/path", false)]
57+
[InlineData("https://bitbucket.example.com/path", false)]
58+
[InlineData("http://bitbucket.example.org", false)]
59+
[InlineData("https://bitbucket.example.org", false)]
60+
[InlineData("http://bitbucket.example.org/path", false)]
61+
[InlineData("https://bitbucket.example.org/path", false)]
62+
[InlineData("http://bitbucket.org.com", false)]
63+
[InlineData("https://bitbucket.org.com", false)]
64+
[InlineData("http://bitbucket.org.com/path", false)]
65+
[InlineData("https://bitbucket.org.com/path", false)]
66+
[InlineData("http://bitbucket.org.org", false)]
67+
[InlineData("https://bitbucket.org.org", false)]
68+
[InlineData("http://bitbucket.org.org/path", false)]
69+
[InlineData("https://bitbucket.org.org/path", false)]
70+
public void BitbucketHostProvider_IsBitbucketOrg_Uri(string str, bool expected)
71+
{
72+
bool actual = BitbucketHostProvider.IsBitbucketOrg(new Uri(str));
73+
Assert.Equal(expected, actual);
74+
}
75+
2476
[Theory]
2577
[InlineData("https", null, false)]
2678
// We report that we support unencrypted HTTP here so that we can fail and

0 commit comments

Comments
 (0)