forked from ovh/terraform-provider-ovh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_cloud_project_containerregistry_ip_restrictions_registry_test.go
80 lines (69 loc) · 2.58 KB
/
data_cloud_project_containerregistry_ip_restrictions_registry_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package ovh
import (
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
const testAccCloudProjectContainerRegistryIPRestrictionsRegistryDataSourceConfig = `
data "ovh_cloud_project_capabilities_containerregistry_filter" "registryCap" {
service_name = "%s"
plan_name = "SMALL"
region = "%s"
}
resource "ovh_cloud_project_containerregistry" "registry" {
service_name = data.ovh_cloud_project_capabilities_containerregistry_filter.registryCap.service_name
plan_id = data.ovh_cloud_project_capabilities_containerregistry_filter.registryCap.id
name = "%s"
region = data.ovh_cloud_project_capabilities_containerregistry_filter.registryCap.region
}
resource "ovh_cloud_project_containerregistry_ip_restrictions_registry" "my-registry-iprestrictions" {
service_name = ovh_cloud_project_containerregistry.registry.service_name
registry_id = ovh_cloud_project_containerregistry.registry.id
ip_restrictions = [
{
ip_block = "121.121.121.121/32"
description = "my awesome ip"
}
]
depends_on = [
ovh_cloud_project_containerregistry.registry
]
}
data "ovh_cloud_project_containerregistry_ip_restrictions_registry" "registry-iprestrictions-data" {
service_name = ovh_cloud_project_containerregistry.registry.service_name
registry_id = ovh_cloud_project_containerregistry.registry.id
depends_on = [
ovh_cloud_project_containerregistry_ip_restrictions_registry.my-registry-iprestrictions
]
}
`
func TestAccCloudProjectContainerIPRestrictionsRegistryDataSource_basic(t *testing.T) {
serviceName := os.Getenv("OVH_CLOUD_PROJECT_SERVICE_TEST")
region := os.Getenv("OVH_CLOUD_PROJECT_CONTAINERREGISTRY_REGION_TEST")
registryName := acctest.RandomWithPrefix(test_prefix)
config := fmt.Sprintf(
testAccCloudProjectContainerRegistryIPRestrictionsRegistryDataSourceConfig,
serviceName,
region,
registryName,
)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheckContainerRegistry(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_containerregistry_ip_restrictions_registry.registry-iprestrictions-data", "ip_restrictions.0.ip_block", "121.121.121.121/32"),
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_containerregistry_ip_restrictions_registry.registry-iprestrictions-data", "ip_restrictions.0.description", "my awesome ip"),
),
},
},
})
}