Skip to content

Commit

Permalink
add https use case test with certs and config and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
valyria257 committed May 24, 2024
1 parent 4895b9e commit b7fe1e9
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
57 changes: 57 additions & 0 deletions internal/services/nginx/nginx_configuration_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ func TestAccConfiguration_basic(t *testing.T) {
})
}

func TestAccConfiguration_withCertificate(t *testing.T) {
data := acceptance.BuildTestData(t, nginx.ConfigurationResource{}.ResourceType(), "test")
r := ConfigurationResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.withCertificate(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccConfiguration_update(t *testing.T) {
data := acceptance.BuildTestData(t, nginx.ConfigurationResource{}.ResourceType(), "test")
r := ConfigurationResource{}
Expand Down Expand Up @@ -103,6 +117,49 @@ resource "azurerm_nginx_configuration" "test" {
`, a.template(data))
}

func (a ConfigurationResource) withCertificate(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
locals {
config_content = base64encode(<<-EOT
http {
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/test.crt;
ssl_certificate_key /etc/nginx/ssl/test.key;
location / {
return 200 "Hello World";
}
}
}
EOT
)
}
resource "azurerm_nginx_certificate" "test" {
name = "acctest"
nginx_deployment_id = azurerm_nginx_deployment.test.id
key_virtual_path = "/etc/nginx/ssl/test.key"
certificate_virtual_path = "/etc/nginx/ssl/test.crt"
key_vault_secret_id = azurerm_key_vault_certificate.test.secret_id
}
resource "azurerm_nginx_configuration" "test" {
nginx_deployment_id = azurerm_nginx_deployment.test.id
root_file = "/etc/nginx/nginx.conf"
config_file {
content = local.config_content
virtual_path = "/etc/nginx/nginx.conf"
}
depends_on = [azurerm_nginx_certificate.test]
}
`, CertificateResource{}.template(data))
}

func (a ConfigurationResource) requiresImport(data acceptance.TestData) string {
return fmt.Sprintf(`
Expand Down
2 changes: 1 addition & 1 deletion internal/services/nginx/nginx_deployment_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ resource "azurerm_nginx_deployment" "test" {
subnet_id = azurerm_subnet.test.id
}
capacity = 10
email = "[email protected]"
email = "[email protected]"
configuration {
root_file = "/etc/nginx/nginx.conf"
config_file {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/nginx_configuration.html.markdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "Nginx"
subcategory: "NGINX"
layout: "azurerm"
page_title: "Azure Resource Manager: Data Source: azurerm_nginx_configuration"
description: |-
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/nginx_configuration.html.markdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "Nginx"
subcategory: "NGINX"
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_nginx_configuration"
description: |-
Expand Down

0 comments on commit b7fe1e9

Please sign in to comment.