package tls import ( "crypto/x509" "encoding/pem" "fmt" "strings" "testing" "time" r "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) func TestSelfSignedCert(t *testing.T) { r.Test(t, r.TestCase{ Providers: testProviders, Steps: []r.TestStep{ r.TestStep{ Config: fmt.Sprintf(` resource "tls_self_signed_cert" "test" { subject { common_name = "example.com" organization = "Example, Inc" organizational_unit = "Department of Terraform Testing" street_address = ["5879 Cotton Link"] locality = "Pirate Harbor" province = "CA" country = "US" postal_code = "95559-1227" serial_number = "2" } dns_names = [ "example.com", "example.net", ] ip_addresses = [ "127.0.0.1", "127.0.0.2", ] validity_period_hours = 1 allowed_uses = [ "key_encipherment", "digital_signature", "server_auth", "client_auth", ] key_algorithm = "RSA" private_key_pem = < (2 * time.Minute) { return fmt.Errorf("certificate validity begins more than two minutes in the past") } if cert.NotAfter.Sub(cert.NotBefore) != time.Hour { return fmt.Errorf("certificate validity is not one hour") } return nil }, }, }, }) }