Last active
October 16, 2017 18:54
-
-
Save skierkowski/d80c8e8932285c3dc99b22c59d1e7195 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$LOAD_PATH.unshift(File.expand_path("./lib")) | |
require 'terraform_enterprise_api' | |
require 'awesome_print' | |
require 'securerandom' | |
@client = TerraformEnterprise::Client.new(api_key: ENV['TERRAFORM_ENTERPRISE_TOKEN']) | |
def test_policy_crud(organization:'000-test-suite',policy_name:"policy-#{SecureRandom.hex(3)}") | |
policy_content = 'main = rule { true }' | |
policy = @client.policies.create(organization:organization,name:policy_name, enforce:[{path:"#{policy_name}.sentinel",mode:'hard-mandatory'}]) | |
@client.policies.upload(policy: policy['id'], content:policy_content) | |
downloaded_policy = @client.policies.download(policy: policy['id']) | |
raise "uploaded policy (#{policy_content}) does not match downloaded policy (downloaded_policy)" unless policy_content == downloaded_policy | |
@client.policies.delete(policy: policy['id']) | |
end | |
test_policy_crud |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment