|
2 | 2 |
|
3 | 3 | import static org.junit.Assert.assertEquals; |
4 | 4 | import static org.junit.Assert.assertNotNull; |
| 5 | +import static org.junit.Assert.assertNull; |
5 | 6 |
|
6 | 7 | import com.cloudbees.jenkins.GitHubRepositoryName; |
7 | 8 |
|
@@ -153,4 +154,90 @@ public void httpsUrlOtherHostNoSuffix() { |
153 | 154 | assertEquals("jenkins", repo.repositoryName); |
154 | 155 | assertEquals("gh.company.com", repo.host); |
155 | 156 | } |
| 157 | + |
| 158 | + @Test |
| 159 | + public void gitAtUrlGitHubTrailingSlash() { |
| 160 | + GitHubRepositoryName repo = GitHubRepositoryName |
| 161 | + . create( "[email protected]:jenkinsci/jenkins/"); |
| 162 | + assertNotNull(repo); |
| 163 | + assertEquals("jenkinsci", repo.userName); |
| 164 | + assertEquals("jenkins", repo.repositoryName); |
| 165 | + assertEquals("github.com", repo.host); |
| 166 | + } |
| 167 | + |
| 168 | + @Test |
| 169 | + public void gitAtUrlOtherHostTrailingSlash() { |
| 170 | + GitHubRepositoryName repo = GitHubRepositoryName |
| 171 | + . create( "[email protected]:jenkinsci/jenkins/"); |
| 172 | + assertNotNull(repo); |
| 173 | + assertEquals("jenkinsci", repo.userName); |
| 174 | + assertEquals("jenkins", repo.repositoryName); |
| 175 | + assertEquals("gh.company.com", repo.host); |
| 176 | + } |
| 177 | + |
| 178 | + @Test |
| 179 | + public void gitColonUrlGitHubTrailingSlash() { |
| 180 | + GitHubRepositoryName repo = GitHubRepositoryName |
| 181 | + .create("git://github.com/jenkinsci/jenkins/"); |
| 182 | + assertNotNull(repo); |
| 183 | + assertEquals("jenkinsci", repo.userName); |
| 184 | + assertEquals("jenkins", repo.repositoryName); |
| 185 | + assertEquals("github.com", repo.host); |
| 186 | + } |
| 187 | + |
| 188 | + @Test |
| 189 | + public void gitColonUrlOtherHostTrailingSlash() { |
| 190 | + GitHubRepositoryName repo = GitHubRepositoryName |
| 191 | + .create("git://company.net/jenkinsci/jenkins/"); |
| 192 | + assertNotNull(repo); |
| 193 | + assertEquals("jenkinsci", repo.userName); |
| 194 | + assertEquals("jenkins", repo.repositoryName); |
| 195 | + assertEquals("company.net", repo.host); |
| 196 | + } |
| 197 | + |
| 198 | + @Test |
| 199 | + public void httpsUrlGitHubTrailingSlash() { |
| 200 | + GitHubRepositoryName repo = GitHubRepositoryName |
| 201 | + . create( "https://[email protected]/jenkinsci/jenkins/"); |
| 202 | + assertNotNull(repo); |
| 203 | + assertEquals("jenkinsci", repo.userName); |
| 204 | + assertEquals("jenkins", repo.repositoryName); |
| 205 | + assertEquals("github.com", repo.host); |
| 206 | + } |
| 207 | + |
| 208 | + @Test |
| 209 | + public void httpsUrlGitHubWithoutUserTrailingSlash() { |
| 210 | + //this is valid for anonymous usage |
| 211 | + GitHubRepositoryName repo = GitHubRepositoryName |
| 212 | + .create("https://github.com/jenkinsci/jenkins/"); |
| 213 | + assertNotNull(repo); |
| 214 | + assertEquals("jenkinsci", repo.userName); |
| 215 | + assertEquals("jenkins", repo.repositoryName); |
| 216 | + assertEquals("github.com", repo.host); |
| 217 | + } |
| 218 | + |
| 219 | + @Test |
| 220 | + public void httpsUrlOtherHostTrailingSlash() { |
| 221 | + GitHubRepositoryName repo = GitHubRepositoryName |
| 222 | + . create( "https://[email protected]/jenkinsci/jenkins/"); |
| 223 | + assertNotNull(repo); |
| 224 | + assertEquals("jenkinsci", repo.userName); |
| 225 | + assertEquals("jenkins", repo.repositoryName); |
| 226 | + assertEquals("gh.company.com", repo.host); |
| 227 | + } |
| 228 | + |
| 229 | + @Test |
| 230 | + public void badProtocol() { |
| 231 | + GitHubRepositoryName repo = GitHubRepositoryName |
| 232 | + .create("gopher://gopher.floodgap.com"); |
| 233 | + assertNull(repo); |
| 234 | + } |
| 235 | + |
| 236 | + @Test |
| 237 | + public void missingColon() { |
| 238 | + GitHubRepositoryName repo = GitHubRepositoryName |
| 239 | + .create("https//github.com/jenkinsci/jenkins"); |
| 240 | + assertNull(repo); |
| 241 | + } |
| 242 | + |
156 | 243 | } |
0 commit comments