Skip to content

Commit

Permalink
Merge branch 'master' into ReadSecretAccessKey
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-rce authored Aug 5, 2024
2 parents 201632e + 5664331 commit 56bc1be
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 139 deletions.
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ tofu-examples:
@sh -c "'$(CURDIR)/scripts/tofu-examples.sh'"

.PHONY: test-integration
test-integration:
test-integration: test-gen-cert
@sh -c "'$(CURDIR)/scripts/integration.sh'"

.PHONY: test-gen-cert
Expand Down
10 changes: 6 additions & 4 deletions outscale/data_source_outscale_api_access_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package outscale
import (
"context"
"fmt"
"os"
"testing"
"time"

Expand All @@ -15,13 +16,14 @@ import (
func TestAccDataOutscaleApiAccessRules_basic(t *testing.T) {
t.Parallel()
resourceName := "outscale_api_access_rule.rule_data"
ca_path := os.Getenv("CA_PATH")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccDataCheckOutscaleApiAccessRuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccDataOutscaleApiAccessRulesConfig(),
Config: testAccDataOutscaleApiAccessRulesConfig(ca_path),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleApiAccessRuleExists(resourceName),
),
Expand Down Expand Up @@ -68,10 +70,10 @@ func testAccDataCheckOutscaleApiAccessRulesDestroy(s *terraform.State) error {
return nil
}

func testAccDataOutscaleApiAccessRulesConfig() string {
func testAccDataOutscaleApiAccessRulesConfig(cert_path string) string {
return fmt.Sprintf(`
resource "outscale_ca" "ca_rule" {
ca_pem = file("./test-cert.pem")
ca_pem = file("%q")
description = "Ca testacc create"
}
Expand Down Expand Up @@ -99,5 +101,5 @@ data "outscale_api_access_rules" "filters_rules" {
}
data "outscale_api_access_rules" "all_rules" {}
`)
`, cert_path)
}
29 changes: 15 additions & 14 deletions outscale/resource_outscale_nic.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,28 +363,29 @@ func ResourceOutscaleNicRead(d *schema.ResourceData, meta interface{}) error {
return err
}

y := make([]map[string]interface{}, len(eni.GetPrivateIps()))
privateIps := make([]map[string]interface{}, len(eni.GetPrivateIps()))
if eni.PrivateIps != nil {
for k, v := range eni.GetPrivateIps() {
b := make(map[string]interface{})
privIp := make(map[string]interface{})

d := make(map[string]interface{})
if assoc, ok := v.GetLinkPublicIpOk(); ok {
d["public_ip_id"] = assoc.GetPublicIpId()
d["link_public_ip_id"] = assoc.GetLinkPublicIpId()
d["public_ip_account_id"] = assoc.GetPublicIpAccountId()
d["public_dns_name"] = assoc.GetPublicDnsName()
d["public_ip"] = assoc.GetPublicIp()
b["link_public_ip"] = d
linkPubIp := []map[string]interface{}{{
"public_ip_id": assoc.GetPublicIpId(),
"link_public_ip_id": assoc.GetLinkPublicIpId(),
"public_ip_account_id": assoc.GetPublicIpAccountId(),
"public_dns_name": assoc.GetPublicDnsName(),
"public_ip": assoc.GetPublicIp(),
}}
privIp["link_public_ip"] = linkPubIp
}
b["private_dns_name"] = v.GetPrivateDnsName()
b["private_ip"] = v.GetPrivateIp()
b["is_primary"] = v.GetIsPrimary()
privIp["private_dns_name"] = v.GetPrivateDnsName()
privIp["private_ip"] = v.GetPrivateIp()
privIp["is_primary"] = v.GetIsPrimary()

y[k] = b
privateIps[k] = privIp
}
}
if err := d.Set("private_ips", y); err != nil {
if err := d.Set("private_ips", privateIps); err != nil {
return err
}

Expand Down
22 changes: 16 additions & 6 deletions scripts/generate-certificate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ set -e

project_dir=$(cd "$(dirname $0)" && pwd)
project_root=$(cd $project_dir/.. && pwd)
if [ ! -d "$project_root/tests/qa_provider_oapi/data/cert_example" ]; then
mkdir $project_root/tests/qa_provider_oapi/data/cert_example
fi
build_dir=$(cd $project_root/tests/qa_provider_oapi/data/cert_example && pwd)
tf_file="gen-cert-test.tf"

cd $project_root
Expand All @@ -20,23 +24,29 @@ terraform {
resource "shell_script" "ca_gen" {
lifecycle_commands {
create = <<-EOF
openssl req -x509 -sha256 -nodes -newkey rsa:4096 -keyout test-cert.key -days 2 -out test-cert.pem -subj /CN=domain.com
openssl req -x509 -sha256 -nodes -newkey rsa:4096 -keyout certificate.key -days 2 -out certificate.pem -subj /CN=domain.com
EOF
read = <<-EOF
echo "{\"filename\": \"test-cert.pem\"}"
echo "{\"filename\": \"certificate.pem\"}"
EOF
delete = ""
}
working_directory = path.module
}
' > "outscale/$tf_file"
' | tee "$project_root/outscale/$tf_file" "$build_dir/$tf_file"

if [ ! -e "outscale/$tf_file" ]; then
if [ ! -e "$build_dir/$tf_file" ] && [ ! -e "$project_root/outscale/$tf_file" ]; then
echo " $tf_file doesn't existe"
exit 1
fi

cd $project_root/outscale && terraform init || exit 1
cd $project_root/outscale && terraform apply -auto-approve || exit 1
cd outscale/
terraform init || exit 1
terraform apply -auto-approve || exit 1

cd $build_dir
terraform init || exit 1
terraform apply -auto-approve || exit 1
cd $project_root

exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@
"attributes": {
"api_access_rule_id": "##id-0##",
"ca_ids": [
"##id-2##",
"##id-1##"
"##id-1##",
"##id-2##"
],
"cns": [
"outscale-1",
Expand Down Expand Up @@ -193,10 +193,10 @@
"schema_version": 0,
"attributes": {
"ca_fingerprint": "########",
"ca_id": "##id-2##",
"ca_id": "##id-1##",
"ca_pem": "########",
"description": "",
"id": "##id-2##",
"id": "##id-1##",
"request_id": "########"
},
"sensitive_attributes": [],
Expand All @@ -214,10 +214,10 @@
"schema_version": 0,
"attributes": {
"ca_fingerprint": "########",
"ca_id": "##id-1##",
"ca_id": "##id-2##",
"ca_pem": "########",
"description": "",
"id": "##id-1##",
"id": "##id-2##",
"request_id": "########"
},
"sensitive_attributes": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"schema_version": 0,
"attributes": {
"ca_fingerprint": "########",
"ca_id": "##id-1##",
"ca_id": "##id-2##",
"ca_pem": "########",
"description": "",
"id": "##id-1##",
"id": "##id-2##",
"request_id": "########"
},
"sensitive_attributes": [],
Expand All @@ -68,10 +68,10 @@
"schema_version": 0,
"attributes": {
"ca_fingerprint": "########",
"ca_id": "##id-2##",
"ca_id": "##id-1##",
"ca_pem": "########",
"description": "",
"id": "##id-2##",
"id": "##id-1##",
"request_id": "########"
},
"sensitive_attributes": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
{
"ca_fingerprint": "########",
"ca_id": "##id-0##",
"description": "test-TF199"
"description": "test-TF199-2"
},
{
"ca_fingerprint": "########",
"ca_id": "##id-1##",
"description": "test-TF199-2"
"description": "test-TF199"
}
],
"filter": "########",
Expand All @@ -47,12 +47,12 @@
{
"ca_fingerprint": "########",
"ca_id": "##id-0##",
"description": "test-TF199"
"description": "test-TF199-2"
},
{
"ca_fingerprint": "########",
"ca_id": "##id-1##",
"description": "test-TF199-2"
"description": "test-TF199"
}
],
"filter": "########",
Expand All @@ -73,10 +73,10 @@
"schema_version": 0,
"attributes": {
"ca_fingerprint": "########",
"ca_id": "##id-0##",
"ca_id": "##id-1##",
"ca_pem": "########",
"description": "test-TF199",
"id": "##id-0##",
"id": "##id-1##",
"request_id": "########"
},
"sensitive_attributes": [],
Expand All @@ -94,10 +94,10 @@
"schema_version": 0,
"attributes": {
"ca_fingerprint": "########",
"ca_id": "##id-1##",
"ca_id": "##id-0##",
"ca_pem": "########",
"description": "test-TF199-2",
"id": "##id-1##",
"id": "##id-0##",
"request_id": "########"
},
"sensitive_attributes": [],
Expand Down
52 changes: 0 additions & 52 deletions tests/qa_provider_oapi/data/cert_example/certificate.key

This file was deleted.

29 changes: 0 additions & 29 deletions tests/qa_provider_oapi/data/cert_example/certificate.pem

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -84,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AirT98wDwYDVR0TAQH/BAUwAwEB/zANBgkq\nhkiG9w0BAQsFAAOCAgEAJoGwCHZlnS/kBhU6pymzsw/t1MbJGEZIfCoAjQ0KtOB2\nArCejR1BEXHbNOt3d7Ei7kCzUveEgwkqPHwV9ryrEKvXspWCZ1T0e+21OFhaPv8B\nlDQ6n7uMW8vWETX9WO8NbjIJTgUKAea9PtOzJTO+W9HbrgjM7gOM9/NvopzrjKVU\nlTcZLAvx4gLhKdlAnhxMdI//+oPyuEciq7ejUNIAlGJaauMmTh1tqIzjnBk32762\negP+W6M5mgIONgiUwDJsIYx7D7GHu3i1XvKRo0+C32cGgNvwFCUQg60Si/paIJMo\nMk0SrgRk5i/kPKfkkTMi26VmGnfeWT2jkESzX0ozBPkzlqQVON/8enHMl6V94wIE\ngq8im6IjJcKvfNoyAXN+ftdD9Uk1D3llUaycGH+adMj4Bb3UqdyMCC3YFeVNgae5\nVadGFDcKA4J/RgCL0rGsZ1jMvt5nWH2mWyGYrHnvkWLHsCIW9EuZDksfUfQSBa8M\n+DOwmDXyUZrYaAfHlgreNfgJrz4C5uFodORDQvu0SM89ex03TccZ2lh3eympkOvv\nO2H6SkF7uq3Sy8wmUjdRL00jqhvqPWVbbpXOMEkuBAlCYpMXEFjbOFCNKSOV5vJ/\n2ckco2bu15h8klyc6w9E18vX/vY1ofp07wNGVPhAVyaxZPjPMGp6gkmnbyY7yIU=\n-----END CERTIFICATE-----\n",
"chain": null,
"body": "########",
"chain": "########",
"dry_run": null,
"expiration_date": "",
"id": "##id-3##",
Expand Down
Loading

0 comments on commit 56bc1be

Please sign in to comment.