Skip to content

Commit

Permalink
Merge pull request #179 from jtobard/fix/177
Browse files Browse the repository at this point in the history
Fix for Keys list
  • Loading branch information
gschueler authored May 14, 2018
2 parents 2c99f13 + da9c1cb commit 833e4f6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -80,6 +81,9 @@ public void setMeta(Map<String, String> meta) {
}

public List<KeyStorageItem> getResources() {
if(resources == null){
return new ArrayList<>();
}
return resources;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/rundeck/client/tool/commands/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ interface PathArgs {
@Option(shortName = "p",
longName = "path",
description = "Storage path in the form 'path/to/file', or 'keys/path/to/file'.",
defaultToNull = true)
defaultValue = "")
Path getPath();
}

Expand Down
29 changes: 29 additions & 0 deletions src/test/groovy/org/rundeck/client/tool/commands/KeysSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,33 @@ class KeysSpec extends Specification {
'asdf😀\r\n' | 'asdf😀'

}

@Unroll
def "list all"() {
given:
def api = Mock(RundeckApi)
def opts = Mock(Keys.ListArg) {
getPath() >> new Keys.Path(input?:"")

}

def retrofit = new Retrofit.Builder().baseUrl('http://example.com/fake/').build()
def client = new Client(api, retrofit, null, null, 18, true, null)
def hasclient = Mock(RdApp) {
getClient() >> client
}
Keys keys = new Keys(hasclient)
def out = Mock(CommandOutput)
when:
keys.list(opts, out)

then:
1 * api.listKeyStorage(_) >> Calls.response(new KeyStorageItem())
0 * api._(*_)

where:
input | _
null | _
'keys/' | _
}
}

0 comments on commit 833e4f6

Please sign in to comment.