Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Test/iam auth #100

Merged
merged 4 commits into from
Oct 11, 2018
Merged

Test/iam auth #100

merged 4 commits into from
Oct 11, 2018

Conversation

Etiene
Copy link
Contributor

@Etiene Etiene commented Oct 10, 2018

  • Refactors vault test helper
  • Bumps version of consul cluster module on examples
  • Adds vault iam auth example

There still an intermittent test issue going on (from before this PR, which continues to happen through this PR). Josh suggested to use Eugene's new feature. I agree! I am thinking about tackling it in a different PR though. What do you think?

@josh-padnick
Copy link
Collaborator

I am thinking about tackling it in a different PR though. What do you think?

Sounds like a good idea. I'll review the rest of this PR now.

Copy link
Collaborator

@josh-padnick josh-padnick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Left some minor comments on code improvement, but otherwise ready to merge. One sanity check: These tests run with the open source Vault, not Vault Enterprise, correct?

test_structure.SaveTerraformOptions(t, examplesDir, terraformOptions)

terraform.InitAndApply(t, terraformOptions)
deployCluster(t, examplesDir, random.UniqueId(), map[string]interface{}{})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you replace map[string]interface{}{} with just nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

// 2. Building the AMI in the vault-consul-ami example with the given build name
// 3. Deploying that AMI using the example Terraform code setting an example secret
// 4. Waiting for Vault to boot, unseal and the client to fetch the secret
// 5. Making a request to the webserver started by the auth client user data script to see if the secret was properly fetched
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice description of the test, but it doesn't mention Vault IAM auth explicitly anywhere? Perhaps clarify in the last line that you're using Vault IAM Auth to auth the client? Also can you make it clear that you're not "waiting for vault" to unseal; rather, the test will unseal Vault.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok!

VAR_SSH_KEY_NAME: keyPair.Name,
} {
terraformVars[key] = value
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clever but somewhat unusual way to just merge two maps. Can you make this more clear by writing your own mini merge function that's more generic in nature and then call that? Should make the code more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!

Vars: terraformVars,
EnvVars: map[string]string{
ENV_VAR_AWS_REGION: awsRegion,
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we're dynamically generating all the vars, should we just pass in the awsRegion directly to the Terraform vars and avoid the use of EnvVars altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could. I was just following the previous examples that use data "aws_region" "current" {} and get it through env. That could be removed and we can pass it as vars, but I honestly don't see what's the difference and what would be the advantage of doing that over what was being done before. Could you help me understand?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I honestly don't see what's the difference

Actually, that was my thought exactly. But if there's no difference, and you see a different way of handling one particular var then it makes the reader question why it's being used that way (as I did). So I'm just trying to minimize the potential confusion readers will have.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! I'll take a note to do this in a separate PR if you don't mind because I just did the vault auto-unseal branching off this one

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine. FYI, you could always do the following if you wanted to keep everything self-contained:

  1. Make the desired change on this branch
  2. git checkout <vault-auto-unseal-branch>
  3. `git rebase -i
  4. git push -f

But careful with that last step. Once you do a git push -f (git push force), you'll overwrite what ever's currently on the remote branch in GitHub.

@Etiene
Copy link
Contributor Author

Etiene commented Oct 11, 2018

These tests run with the open source Vault, not Vault Enterprise, correct?

Well, the vault enterprise cluster test runs with Vault Enterprise installed, so will the auto unseal test that I'm working on right now (coming on another PR). All the others run with the open source vault.

@josh-padnick
Copy link
Collaborator

Well, the vault enterprise cluster test runs with Vault Enterprise installed, so will the auto unseal test that I'm working on right now (coming on another PR). All the others run with the open source vault.

So, this is Vault open source then? My point is that we should default to using Vault open source since it's the free version and only use Vault Enterprise in the examples when the examples specifically calls for it.

@Etiene
Copy link
Contributor Author

Etiene commented Oct 11, 2018

So, this is Vault open source then? My point is that we should default to using Vault open source since it's the free version and only use Vault Enterprise in the examples when the examples specifically calls for it.

Yes, this is exactly how it works already

@Etiene Etiene merged commit 9b86886 into master Oct 11, 2018
@Etiene Etiene deleted the test/iam-auth branch October 11, 2018 18:18
@Etiene
Copy link
Contributor Author

Etiene commented Oct 11, 2018

Notify
@infosecgithub
@bgt101

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants