Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Fix sigh renew password set through environment
Browse files Browse the repository at this point in the history
Description
===========

This is a small patch which only involves to bump
`com.wooga.gradle:gradle-commons` to min version `1.5.1`.
We need the functionality of the `ExecSpec`/`ProcessExecutor` to handle
environment values correctly. The latest version had a bug and was not
pushing the values provided in the environment map to the executable.

I adjusted the tests to actually test the values being passed to the
called process instead of checking the task properties only.

Changes
=======

* ![FIX] sigh renew password set through environment
  • Loading branch information
Larusso committed Jul 19, 2022
1 parent 9804aee commit 0b57aa5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 38 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ cveHandler {
}

dependencies {
implementation 'com.wooga.gradle:gradle-commons:[1,2['
implementation 'com.wooga.gradle:gradle-commons:[1.5.1,2['
testImplementation 'com.wooga.gradle:gradle-commons-test:[1,2['
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package wooga.gradle.fastlane

import com.wooga.gradle.test.BatchmodeWrapper

import java.nio.file.Paths

Expand All @@ -25,14 +26,9 @@ abstract class FastlaneIntegrationSpec extends IntegrationSpec {
File fastlaneMockPath

def setupFastlaneMock() {
fastlaneMockPath = File.createTempDir("fastlane", "mock")
fastlaneMock = createFile("fastlane", fastlaneMockPath)
fastlaneMock.executable = true
fastlaneMock << """
#!/usr/bin/env bash
echo \$@
env
""".stripIndent()
fastlaneMock = new BatchmodeWrapper("fastlane").withEnvironment(true).toTempFile()
fastlaneMockPath = fastlaneMock.parentFile

}

def setup() {
Expand All @@ -43,8 +39,6 @@ abstract class FastlaneIntegrationSpec extends IntegrationSpec {
""".stripIndent()
}



// TODO: Replace with newer test API. subStr is an object since we invoke this for any types then discard
Object substitutePath(Object expectedValue, Object value, String typeName) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,28 @@ class SighRenewIntegrationSpec extends AbstractFastlaneTaskIntegrationSpec {

@Unroll("property #property #valueMessage sets flag #expectedCommandlineFlag")
def "constructs arguments"() {
given: "a task to read the build arguments"
buildFile << """
task("readValue") {
doLast {
println("arguments: " + ${getTestTaskName()}.arguments.get().join(" "))
}
}
""".stripIndent()

and: "a set property"
given: "a set property"
if (method != _) {
buildFile << """
${getTestTaskName()}.${method}($value)
""".stripIndent()
}

and: "a fix for an unknown file"
if(property == "apiKeyPath") {
createFile(rawValue.toString())
}

// TODO: Refactor
and: "a substitution"
expectedCommandlineFlag = substitutePath(expectedCommandlineFlag, rawValue, type)

when:
def result = runTasksSuccessfully("readValue")
def result = runTasksSuccessfully(testTaskName)

then:
outputContains(result, expectedCommandlineFlag)
def argumentsLine = result.standardOutput.split(/\[ARGUMENTS\]\:${System.getProperty("line.separator")}/).last().readLines().first()
argumentsLine.contains(expectedCommandlineFlag)

where:
property | method | rawValue | type || expectedCommandlineFlag
Expand All @@ -86,41 +83,33 @@ class SighRenewIntegrationSpec extends AbstractFastlaneTaskIntegrationSpec {
"ignoreProfilesWithDifferentName" | "ignoreProfilesWithDifferentName.set" | false | "Boolean" || "--ignore_profiles_with_different_name false"
"ignoreProfilesWithDifferentName" | _ | _ | "Boolean" || "--ignore_profiles_with_different_name false"
"fileName" | "fileName.set" | "test2.mobileprovisioning" | "String" || "--filename test2.mobileprovisioning"
"destinationDir" | "destinationDir.set" | "/some/path" | "File" || "--output_path /some/path"
"destinationDir" | "destinationDir.set" | "some/path" | "File" || "--output_path some/path"
"additionalArguments" | "setAdditionalArguments" | ["--verbose", "--foo bar"] | "List<String>" || "--verbose --foo bar"
"apiKeyPath" | "apiKeyPath.set" | "/path/to/key.json" | "File" || "--api-key-path /path/to/key.json"
"apiKeyPath" | "apiKeyPath.set" | "path/to/key.json" | "File" || "--api-key-path path/to/key.json"
value = wrapValueBasedOnType(rawValue, type)
valueMessage = (rawValue != _) ? "with value ${value}" : "without value"
}

@Unroll("property #property #valueMessage sets environment #expectedEnvironmentPair")
def "constructs process environment"() {
given: "a task to read the build arguments"
buildFile << """
task("readValue") {
doLast {
println("arguments: " + ${getTestTaskName()}.environment.get().collect {k,v -> k + '=' + v}.join("\\n"))
}
}
""".stripIndent()

and: "a set property"
given: "a set property"
if (method != _) {
buildFile << """
${getTestTaskName()}.${method}($value)
""".stripIndent()
}

when:
def result = runTasksSuccessfully("readValue")
def result = runTasksSuccessfully(testTaskName)

then:
outputContains(result, expectedEnvironmentPair)
def environmentsLines = result.standardOutput.split(/\[ENVIRONMENT\]\:${System.getProperty("line.separator")}/).last().readLines()
environmentsLines.contains(expectedEnvironmentPair)

where:
property | method | rawValue | type || expectedEnvironmentPair
"password" | "password.set" | "secretValue" | "String" || "FASTLANE_PASSWORD=secretValue"
"skip2faUpgrade" | "skip2faUpgrade.set" | true | "BOLEAN" || "SPACESHIP_SKIP_2FA_UPGRADE=1"
"skip2faUpgrade" | "skip2faUpgrade.set" | true | "Bolean" || "SPACESHIP_SKIP_2FA_UPGRADE=1"
value = wrapValueBasedOnType(rawValue, type)
valueMessage = (rawValue != _) ? "with value ${value}" : "without value"
}
Expand Down

0 comments on commit 0b57aa5

Please sign in to comment.