-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
128 additions
and
27 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
src/main/groovy/io/codearte/gradle/nexus/NexusStagingExtension.groovy
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
36 changes: 35 additions & 1 deletion
36
src/test/groovy/io/codearte/gradle/nexus/functional/PasswordFunctionalSpec.groovy
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,13 +1,47 @@ | ||
package io.codearte.gradle.nexus.functional | ||
|
||
import org.codehaus.groovy.runtime.StackTraceUtils | ||
|
||
class PasswordFunctionalSpec extends BaseNexusStagingFunctionalSpec { | ||
|
||
def "should read password from repository configured in uploadArchives"() { | ||
given: | ||
copyResources("sampleProjects//uploadArchives", "") | ||
file("gradle.properties") << "\nsonatypeUsername=testUsername" << "\nsonatypePassword=testPassword" | ||
when: | ||
def result = runTasksSuccessfully('tasks') | ||
def result = runTasksWithFailure('getStagingProfile') | ||
then: | ||
assertFailureWithConnectionRefused(result.failure) | ||
and: | ||
result.standardOutput.contains("Using username 'testUsername' and password from repository 'Test repo'") | ||
} | ||
|
||
def "should read username and password from property when available"() { | ||
given: | ||
copyResources("sampleProjects//uploadArchives", "") | ||
file("gradle.properties") << "\nnexusUsername=nexusTestUsername" << "\nnexusPassword=nexusTestPassword" | ||
when: | ||
def result = runTasksWithFailure('getStagingProfile', '--build-file', 'build-property.gradle') | ||
then: | ||
assertFailureWithConnectionRefused(result.failure) | ||
and: | ||
//Cannot assert precisely as those values can be overridden by user's ~/.gradle/gradle.properties | ||
result.standardOutput.contains("Using password '*****' from Gradle property") //TODO: matching with regexp | ||
} | ||
|
||
def "should not try read username and password when release tasks are not executed"() { | ||
given: | ||
copyResources("sampleProjects//uploadArchives", "") | ||
file("gradle.properties") << "\nnexusUsername=nexusTestUsername" << "\nnexusPassword=nexusTestPassword" | ||
when: | ||
def result = runTasksSuccessfully('tasks', '--build-file', 'build-property.gradle') | ||
then: | ||
!result.standardOutput.contains("Using password '*****' from Gradle property") //TODO: matching with regexp | ||
} | ||
|
||
private static void assertFailureWithConnectionRefused(Throwable failure) { | ||
Throwable rootCause = StackTraceUtils.extractRootCause(failure) | ||
rootCause.getClass() == ConnectException | ||
rootCause.message == "Connection refused" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/resources/sampleProjects/uploadArchives/build-property.gradle
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,22 @@ | ||
apply plugin: 'groovy' | ||
apply plugin: 'io.codearte.nexus-staging' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile 'org.codehaus.groovy:groovy-all:2.3.7' | ||
|
||
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0' | ||
testCompile 'junit:junit:4.11' | ||
} | ||
|
||
artifacts { | ||
archives jar | ||
} | ||
|
||
nexusStaging { | ||
serverUrl = 'http://localhost:8089/nexus/' | ||
packageGroup = "io.codearte" | ||
} |
2 changes: 0 additions & 2 deletions
2
src/test/resources/sampleProjects/uploadArchives/gradle.properties
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,4 +1,2 @@ | ||
group=com.example.upload1 | ||
version=0.0.1-SNAPSHOT | ||
sonatypeUsername=testUsername | ||
sonatypePassword=testPassword |