Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from damnhandy/master
Added code to ensure that passwords are not included git.remote.origin.url
- Loading branch information
Showing
4 changed files
with
105 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/test/java/pl/project13/maven/git/UriUserInfoRemoverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package pl.project13.maven.git; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.apache.http.client.utils.URIBuilder; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
/** | ||
* Created by ryan on 3/21/16. | ||
*/ | ||
public class UriUserInfoRemoverTest { | ||
|
||
@Test | ||
public void testHttpsUriWithoutUserInfo() throws Exception { | ||
String result = GitDataProvider.stripCredentialsFromOriginUrl("https://example.com"); | ||
assertEquals("https://example.com", result); | ||
} | ||
|
||
@Test | ||
public void testHttpsUriWithUserInfo() throws Exception { | ||
String result = GitDataProvider.stripCredentialsFromOriginUrl("https://user@example.com"); | ||
assertEquals("https://user@example.com", result); | ||
} | ||
|
||
@Test | ||
public void testHttpsUriWithUserInfoAndPassword() throws Exception { | ||
String result = GitDataProvider.stripCredentialsFromOriginUrl("https://user:password@example.com"); | ||
assertEquals("https://user@example.com", result); | ||
} | ||
|
||
@Test | ||
public void testWithSCPStyleSSHProtocolGitHub() throws Exception { | ||
String result = GitDataProvider.stripCredentialsFromOriginUrl("git@github.com"); | ||
assertEquals("git@github.com",result); | ||
} | ||
|
||
@Test | ||
public void testWithSCPStyleSSHProtocol() throws Exception { | ||
String result = GitDataProvider.stripCredentialsFromOriginUrl("user@host.xz:~user/path/to/repo.git"); | ||
assertEquals("user@host.xz:~user/path/to/repo.git",result); | ||
} | ||
|
||
@Test | ||
public void testWithSSHUri() throws Exception { | ||
String result = GitDataProvider.stripCredentialsFromOriginUrl("ssh://git@github.com/"); | ||
assertEquals("ssh://git@github.com/",result); | ||
} | ||
} |