-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
evaluating env var in git repo URL before clone command
- Loading branch information
1 parent
17ec079
commit 1bfc2af
Showing
4 changed files
with
53 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
33 changes: 33 additions & 0 deletions
33
core/src/test/kotlin/in/specmatic/core/git/GitOperationsTest.kt
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,33 @@ | ||
package `in`.specmatic.core.git | ||
|
||
import org.assertj.core.api.AssertionsForClassTypes.assertThat | ||
import org.junit.jupiter.api.Test | ||
|
||
class GitOperationsTest { | ||
@Test | ||
fun shouldNotChangeGitRepoUrlWhenThereAreNoEnvVariables() { | ||
val gitRepositoryURI = "https://gitlab.com/group/project.git" | ||
val evaluatedGitRepositoryURI = | ||
evaluateEnvVariablesInGitRepoURI(gitRepositoryURI = gitRepositoryURI, emptyMap<String, String>()) | ||
assertThat(evaluatedGitRepositoryURI).isEqualTo(gitRepositoryURI) | ||
} | ||
|
||
@Test | ||
fun shouldChangeGitRepoUrlWhenThereIsOneEnvVariable() { | ||
val gitRepositoryURI = "https://gitlab-ci-token:${'$'}{CI_JOB_TOKEN}@gitlab.com/group/project.git" | ||
val evaluatedGitRepositoryURI = | ||
evaluateEnvVariablesInGitRepoURI(gitRepositoryURI = gitRepositoryURI, mapOf("CI_JOB_TOKEN" to "token")) | ||
assertThat(evaluatedGitRepositoryURI).isEqualTo("https://gitlab-ci-token:[email protected]/group/project.git") | ||
} | ||
|
||
@Test | ||
fun shouldChangeGitRepoUrlWhenThereAreMultipleEnvVariable() { | ||
val gitRepositoryURI = "https://${'$'}{USER_NAME}:${'$'}{PASSWORD}@gitlab.com/group/project.git" | ||
val evaluatedGitRepositoryURI = | ||
evaluateEnvVariablesInGitRepoURI( | ||
gitRepositoryURI = gitRepositoryURI, | ||
mapOf("USER_NAME" to "john", "PASSWORD" to "password") | ||
) | ||
assertThat(evaluatedGitRepositoryURI).isEqualTo("https://john:[email protected]/group/project.git") | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
version=1.3.17 | ||
version=1.3.18 |