From 3595d300df12e9f9d9e496808e6fa70030f846b2 Mon Sep 17 00:00:00 2001 From: "Eirik S. Morland" Date: Sun, 17 Nov 2024 14:34:20 +0100 Subject: [PATCH] Add tests --- src/ToCloneUrl.php | 6 +++++- tests/UnitTest.php | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ToCloneUrl.php b/src/ToCloneUrl.php index 704eaf9..90d6f3d 100644 --- a/src/ToCloneUrl.php +++ b/src/ToCloneUrl.php @@ -58,7 +58,11 @@ public static function fromRepoAndToken(string $repo, string $authToken) : strin case 'www.bitbucket.org': case 'bitbucket.org': - $repo_path = sprintf('https://x-token-auth:%s@bitbucket.org%s', $authToken, $repo_parsed["path"]); + $repo_path = sprintf( + 'https://x-token-auth:%s@bitbucket.org%s', + $authToken, + $repo_parsed["path"] + ); if (strlen($authToken) < 50 && strpos($authToken, ':') !== false) { $repo_path = sprintf( 'https://%s@bitbucket.org%s', diff --git a/tests/UnitTest.php b/tests/UnitTest.php index c2107db..99d3b8f 100644 --- a/tests/UnitTest.php +++ b/tests/UnitTest.php @@ -59,6 +59,21 @@ public static function provideAllCases() : array 'token123', 'https://oauth2:token123@gitlab.com/user/repo.git', ], + [ + 'https://bitbucket.org/user/repo.git', + 'token123', + 'https://x-token-auth:token123@bitbucket.org/user/repo.git', + ], + [ + 'https://www.bitbucket.org/user/repo.git', + 'token123', + 'https://x-token-auth:token123@bitbucket.org/user/repo.git', + ], + [ + 'https://www.bitbucket.org/user/repo.git', + 'user:token123', + 'https://user:token123@bitbucket.org/user/repo.git', + ], ]; } }