-
Notifications
You must be signed in to change notification settings - Fork 36
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 #101 from bshtv/maven-repositories-with-auth-support
Maven repositories with auth support
- Loading branch information
Showing
5 changed files
with
289 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
191 changes: 191 additions & 0 deletions
191
ki-shell/src/test/kotlin/org/jetbrains/kotlinx/ki/shell/plugins/DependenciesPluginTest.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,191 @@ | ||
package org.jetbrains.kotlinx.ki.shell.plugins | ||
|
||
import junit.framework.TestCase | ||
import org.jetbrains.kotlinx.ki.shell.Command | ||
import org.jetbrains.kotlinx.ki.shell.configuration.ReplConfigurationBase | ||
import org.junit.Test | ||
|
||
class DependenciesPluginTest : TestCase() { | ||
|
||
private val repoCommand = DependenciesPlugin().RepositoryCommand(object : ReplConfigurationBase() {}) | ||
|
||
private fun extractSnippetFromCommand(command: Command.Result.RunSnippets): String { | ||
return command.snippetsToRun.toList()[0] | ||
} | ||
|
||
@Test | ||
fun testWhenRepoUrlNotPassed() { | ||
val command = repoCommand.execute(":repository ") as Command.Result.RunSnippets | ||
|
||
assertEquals("@file:Repository(\"\")", extractSnippetFromCommand(command)) | ||
} | ||
|
||
@Test | ||
fun testWhenRepoUrlPassed() { | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\")", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testUsernameAndPasswordEqualSeparator() { | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven username=user password=pass") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=user\", \"password=pass\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testUsernameOnlyEqualSeparator() { | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven username=user barepassword") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=user\", \"password=\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testPasswordOnlyEqualSeparator() { | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven bareusername password=pass") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=\", \"password=pass\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testUsernameWithEqualEqualSeparator() { | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven username=my=user password=pass") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=my=user\", \"password=pass\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testPasswordWithEqualEqualSeparator() { | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven username=user password=my=pass") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=user\", \"password=my=pass\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testUsernameAndPasswordSemicolonSeparator() { | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven username:user password:pass") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=user\", \"password=pass\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testUsernameOnlySemicolonSeparator() { | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven username:user barepassword") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=user\", \"password=\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testPasswordOnlySemicolonSeparator() { | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven bareusername password:pass") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=\", \"password=pass\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testUsernameWithSemicolonSemicolonSeparator() { | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven username:my:user password:pass") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=my:user\", \"password=pass\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testPasswordWithSemicolonSemicolonSeparator() { | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven username:user password:my:pass") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=user\", \"password=my:pass\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testFilenamePassed() { | ||
val filePath = "./src/test/resources/valid.credentials" | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven $filePath") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=fileusername\", \"password=file password\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testNotFoundFilename() { | ||
val filePath = "blabla" | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven $filePath") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=\", \"password=\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testMissingCredentialsFile() { | ||
val filePath = "./src/test/resources/missing.credentials" | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven $filePath") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=\", \"password=\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
|
||
@Test | ||
fun testCredentialsFileIsDirectory() { | ||
val filePath = "./src/test/resources" | ||
val command = repoCommand.execute(":repository https://packages.team/path/to/maven $filePath") | ||
as Command.Result.RunSnippets | ||
|
||
assertEquals( | ||
"@file:Repository(\"https://packages.team/path/to/maven\", options = [\"username=\", \"password=\"])", | ||
extractSnippetFromCommand(command) | ||
) | ||
} | ||
} |
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 @@ | ||
blabla |
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,2 @@ | ||
username=fileusername | ||
password=file password |