Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions openapi/openapi_v2_spec_analyser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ func TestNewSpecAnalyserV2(t *testing.T) {
})

Convey("Given a swagger doc with a circular ref (ref points to itself)", t, func() {
var swaggerJSON = fmt.Sprintf(`{
var swaggerJSON = `{
"swagger":"2.0",
"paths":{
"/v1/cdns":{
Expand All @@ -1675,7 +1675,7 @@ func TestNewSpecAnalyserV2(t *testing.T) {
"$ref":"#/definitions/ContentDeliveryNetwork"
}
}
}`)
}`
swaggerFile := initAPISpecFile(swaggerJSON)
defer os.Remove(swaggerFile.Name())
Convey("When newSpecAnalyserV2 method is called", func() {
Expand All @@ -1697,7 +1697,7 @@ func TestNewSpecAnalyserV2(t *testing.T) {
})

Convey("Given a swagger doc with a ref to a definition that does not exists", t, func() {
var swaggerJSON = fmt.Sprintf(`{
var swaggerJSON = `{
"swagger":"2.0",
"paths":{
"/v1/cdns":{
Expand All @@ -1716,7 +1716,7 @@ func TestNewSpecAnalyserV2(t *testing.T) {
}
}
}
}`)
}`
swaggerFile := initAPISpecFile(swaggerJSON)
defer os.Remove(swaggerFile.Name())
Convey("When newSpecAnalyserV2 method is called", func() {
Expand All @@ -1729,7 +1729,7 @@ func TestNewSpecAnalyserV2(t *testing.T) {
})

Convey("Given a swagger doc with a ref to a definition is wrongly formatted (no empty string)", t, func() {
var swaggerJSON = fmt.Sprintf(`{
var swaggerJSON = `{
"swagger":"2.0",
"paths":{
"/v1/cdns":{
Expand All @@ -1748,7 +1748,7 @@ func TestNewSpecAnalyserV2(t *testing.T) {
}
}
}
}`)
}`
swaggerFile := initAPISpecFile(swaggerJSON)
defer os.Remove(swaggerFile.Name())
Convey("When newSpecAnalyserV2 method is called", func() {
Expand Down
6 changes: 3 additions & 3 deletions openapi/plugin_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestGetServiceProviderConfiguration(t *testing.T) {
os.Unsetenv(otfVarNameUc)
})

Convey(fmt.Sprintf("Given a PluginConfiguration for 'test' provider and a OTF_VAR_test_SWAGGER_URL env variable is not set"), t, func() {
Convey("Given a PluginConfiguration for 'test' provider and a OTF_VAR_test_SWAGGER_URL env variable is not set", t, func() {
pluginConfiguration, _ := NewPluginConfiguration(providerName)
Convey("When getServiceConfiguration is called", func() {
_, err := pluginConfiguration.getServiceConfiguration()
Expand Down Expand Up @@ -215,10 +215,10 @@ services:
})

Convey("Given a PluginConfiguration for 'test' provider and a plugin configuration that DOES NOT contain a service called 'test'", t, func() {
pluginConfig := fmt.Sprintf(`version: '1'
pluginConfig := `version: '1'
services:
some-other-service:
swagger-url: http://some-other-service-api/swagger.yaml`)
swagger-url: http://some-other-service-api/swagger.yaml`
configReader := strings.NewReader(pluginConfig)
pluginConfiguration := PluginConfiguration{
ProviderName: providerName,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/gray_box_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ definitions:
})
assert.NoError(t, err)

tfFileContents := fmt.Sprintf(`
tfFileContents := `
resource "openapi_cdn_v1" "my_cdn_v1" {
label = "my_label"
}`)
}`

resource.Test(t, resource.TestCase{
IsUnitTest: true,
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/provider_plugin_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ services:
PreCheck: func() { testAccPreCheck(t, swaggerServer.URL) },
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Config: `
provider "openapi" {
some_token = "token_value"
some_header = "header_value"
Expand All @@ -172,7 +172,7 @@ data "openapi_cdns_v1" "my_data_cdn" {

data "openapi_cdns_v1_instance" "my_cdn" {
id = "someID"
}`),
}`,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"openapi_cdns_v1.my_cdn", "label", "some_label"),
Expand Down Expand Up @@ -328,7 +328,7 @@ services:
PreCheck: func() { testAccPreCheck(t, swaggerServer.URL) },
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`resource "openapi_cdns_v1" "my_cdn" { label = "some_label"}`),
Config: `resource "openapi_cdns_v1" "my_cdn" { label = "some_label"}`,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"openapi_cdns_v1.my_cdn", "label", "some_label"),
Expand Down
20 changes: 10 additions & 10 deletions tests/e2e/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ definitions:
})
assert.NoError(t, err)

tfFileContents := fmt.Sprintf(`
tfFileContents := `
provider "openapi" {
required_header_example = ""
}

resource "openapi_cdns" "my_cdn" {
label = "some label"
}`)
}`

expectedValidationError, _ := regexp.Compile(".*failed to configure the API request for POST http://127.0.0.1:[\\d]+/cdns: required header 'required_header_example' is missing the value. Please make sure the property 'required_header_example' is configured with a value in the provider's terraform configuration.*")
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -165,13 +165,13 @@ securityDefinitions:
})
assert.NoError(t, err)

tfFileContents := fmt.Sprintf(`
tfFileContents := `
provider "openapi" {
some_not_global_sec_def = ""
}
resource "openapi_cdns" "my_cdn" {
label = "some label"
}`)
}`

expectedValidationError, _ := regexp.Compile(".*failed to configure the API request for POST http://127.0.0.1:[\\d]+/cdns: required security definition 'some_not_global_sec_def' is missing the value. Please make sure the property 'some_not_global_sec_def' is configured with a value in the provider's terraform configuration.*")
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -253,13 +253,13 @@ securityDefinitions:
})
assert.NoError(t, err)

tfFileContents := fmt.Sprintf(`
tfFileContents := `
provider "openapi" {
some_not_global_sec_def = ""
}
resource "openapi_cdns" "my_cdn" {
label = "some label"
}`)
}`

expectedValidationError, _ := regexp.Compile(".*failed to configure the API request for POST http://127.0.0.1:[\\d]+/cdns: required security definition 'some_not_global_sec_def' is missing the value. Please make sure the property 'some_not_global_sec_def' is configured with a value in the provider's terraform configuration.*")
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -342,13 +342,13 @@ securityDefinitions:
})
assert.NoError(t, err)

tfFileContents := fmt.Sprintf(`
tfFileContents := `
provider "openapi" {
some_not_global_sec_def = ""
}
resource "openapi_cdns" "my_cdn" {
label = "some label"
}`)
}`

expectedValidationError, _ := regexp.Compile(".*failed to configure the API request for POST http://127.0.0.1:[\\d]+/cdns: required security definition 'some_not_global_sec_def' is missing the value. Please make sure the property 'some_not_global_sec_def' is configured with a value in the provider's terraform configuration.*")
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -431,7 +431,7 @@ definitions:
})
assert.NoError(t, err)

tfFileContents := fmt.Sprintf(`resource "openapi_deploykey_v1" "my_deploykeyv1" {}`)
tfFileContents := `resource "openapi_deploykey_v1" "my_deploykeyv1" {}`

resource.Test(t, resource.TestCase{
IsUnitTest: true,
Expand Down Expand Up @@ -519,7 +519,7 @@ definitions:
})
assert.NoError(t, err)

tfFileContents := fmt.Sprintf(`resource "openapi_deploykey_v1" "my_deploykeyv1" {}`)
tfFileContents := `resource "openapi_deploykey_v1" "my_deploykeyv1" {}`

resource.Test(t, resource.TestCase{
IsUnitTest: true,
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/provider_plugin_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ resource "%s" "my_cdn" {
}

func TestAccProviderConfiguration_PluginExternalFile_SchemaProperty_DefaultValue(t *testing.T) {
testPluginConfig := fmt.Sprintf(`version: '1'
testPluginConfig := `version: '1'
services:
openapi:
swagger-url: https://localhost:8443/swagger.yaml
insecure_skip_verify: true
schema_configuration:
- schema_property_name: "apikey_auth"
default_value: "apiKeyValue"`)
default_value: "apiKeyValue"`
file := createPluginConfigFile(testPluginConfig)
defer os.Remove(file.Name())
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -254,14 +254,14 @@ services:
}

func TestAccProviderConfiguration_PluginExternalFile_SchemaProperty_ExternalConfiguration_With_Non_Successful_Command(t *testing.T) {
testPluginConfig := fmt.Sprintf(`version: '1'
testPluginConfig := `version: '1'
services:
openapi:
swagger-url: https://localhost:8443/swagger.yaml
insecure_skip_verify: true
schema_configuration:
- schema_property_name: "apikey_auth"
cmd: ["cat", "nonExistingFile"]`)
cmd: ["cat", "nonExistingFile"]`
file := createPluginConfigFile(testPluginConfig)
defer os.Remove(file.Name())
initPluginWithExternalConfigFile(file.Name())
Expand All @@ -273,15 +273,15 @@ services:
}

func TestAccProviderConfiguration_PluginExternalFile_SchemaProperty_ExternalConfiguration_With_Command_With_Timeout(t *testing.T) {
testPluginConfig := fmt.Sprintf(`version: '1'
testPluginConfig := `version: '1'
services:
openapi:
swagger-url: https://localhost:8443/swagger.yaml
insecure_skip_verify: true
schema_configuration:
- schema_property_name: "apikey_auth"
cmd: ["sleep", "2"]
cmd_timeout: 1`)
cmd_timeout: 1`
file := createPluginConfigFile(testPluginConfig)
defer os.Remove(file.Name())
initPluginWithExternalConfigFile(file.Name())
Expand All @@ -292,7 +292,7 @@ services:
}

func TestAccProviderConfiguration_PluginExternalFile_SchemaProperty_ExternalConfiguration_FileNotExists(t *testing.T) {
testPluginConfig := fmt.Sprintf(`version: '1'
testPluginConfig := `version: '1'
services:
openapi:
swagger-url: https://localhost:8443/swagger.yaml
Expand All @@ -303,7 +303,7 @@ services:
schema_property_external_configuration:
content_type: json
key_name: $.apikey_auth
file: /path_to_non_existing_file.json`)
file: /path_to_non_existing_file.json`
file := createPluginConfigFile(testPluginConfig)
defer os.Remove(file.Name())
initPluginWithExternalConfigFile(file.Name())
Expand Down