BetterCloud / vault-java-driver

Zero-dependency Java client for HashiCorp's Vault
https://bettercloud.github.io/vault-java-driver/
335 stars 224 forks source link

Cannot use 'logical().write()' with arrays/lists #169

Open sergeytrasko opened 5 years ago

sergeytrasko commented 5 years ago

I'm trying to create identity group with a code snippet like this:

Map<String, Object> params = new HashMap<>();
params.put("name", "test);
params.put("type", "internal");
params.put("member_group_ids", Arrays.asList("1", "2"));

Vault vault = ...;
vault.logical().write("identity/group", params);

This request fails on Vault side with an error saying that member group ID is not found.

Reason is that this code ends up here https://github.com/BetterCloud/vault-java-driver/blob/master/src/main/java/com/bettercloud/vault/api/Logical.java#L246 where List is converted to String.

The request that is sent to Vault is:

{
  "name": "test",
  "type": "internal",
  "member_group_ids": "[\"1\", \"2\"]"
}

Expected request:

{
  "name": "test",
  "type": "internal",
  "member_group_ids": ["1", "2"]
}