Skip to content

Commit

Permalink
Fix supported patterns and extended tests (#5811)
Browse files Browse the repository at this point in the history
* fix(partner center sell): fix supported attributes option

Signed-off-by: Peter Harasztia <[email protected]>

* fix(partner center sell): extend tests

Signed-off-by: Peter Harasztia <[email protected]>

* fix iam test

Signed-off-by: Peter Harasztia <[email protected]>

* fix merge conflict

Signed-off-by: Peter Harasztia <[email protected]>

---------

Signed-off-by: Peter Harasztia <[email protected]>
  • Loading branch information
HarasztiaPeter authored Dec 19, 2024
1 parent d5beb7b commit e95172e
Show file tree
Hide file tree
Showing 15 changed files with 757 additions and 66 deletions.
2 changes: 1 addition & 1 deletion examples/ibm-partner-center-sell/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ resource "ibm_onboarding_iam_registration" "onboarding_iam_registration_instance
options {
operators = [ "stringEquals" ]
hidden = true
supported_attributes = [ "supported_attributes" ]
supported_patterns = [ "supported_patterns" ]
policy_types = [ "access" ]
is_empty_value_supported = true
is_string_exists_false_value_supported = true
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ require (
github.com/IBM/logs-router-go-sdk v1.0.5
github.com/IBM/mqcloud-go-sdk v0.2.0
github.com/IBM/networking-go-sdk v0.49.0
github.com/IBM/platform-services-go-sdk v0.70.0
github.com/IBM/platform-services-go-sdk v0.71.1
github.com/IBM/project-go-sdk v0.3.5
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5
github.com/IBM/sarama v1.41.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ github.com/IBM/mqcloud-go-sdk v0.2.0 h1:QOWk8ZGk0QfIL0MOGTKzNdM3Qe0Hk+ifAFtNSFQo
github.com/IBM/mqcloud-go-sdk v0.2.0/go.mod h1:VZQKMtqmcdXKhmLhLiPuS/UHMs/5yo2tA/nD83cQt9E=
github.com/IBM/networking-go-sdk v0.49.0 h1:lPS34u3C0JVrbxH+Ulua76Nwl6Frv8BEfq6LRkyvOv0=
github.com/IBM/networking-go-sdk v0.49.0/go.mod h1:G9CKbmPE8gSLjN+ABh4hIZ1bMx076enl5Eekvj6zQnA=
github.com/IBM/platform-services-go-sdk v0.70.0 h1:G/jEzG/8SEEc+ZDXqAsPGPWcWD2UGy99LBhPX5iiD2E=
github.com/IBM/platform-services-go-sdk v0.70.0/go.mod h1:1yvG28ExlZ09gfBPH7flAQ6eZf7kYA4hbEEyYlbT97Y=
github.com/IBM/platform-services-go-sdk v0.71.1 h1:EyqSctlLVqj092yU6K9hyTyx7JIpzhE192n6eG+Daac=
github.com/IBM/platform-services-go-sdk v0.71.1/go.mod h1:ApFkvqw7NaluWJ5Uq+afdM/2jQqo5ILc0SzKSVobYNw=
github.com/IBM/project-go-sdk v0.3.5 h1:L+YClFUa14foS0B/hOOY9n7sIdsT5/XQicnXOyJSpyM=
github.com/IBM/project-go-sdk v0.3.5/go.mod h1:FOJM9ihQV3EEAY6YigcWiTNfVCThtdY8bLC/nhQHFvo=
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Mozilla Public License v2.0

/*
* IBM OpenAPI Terraform Generator Version: 3.96.0-d6dec9d7-20241008-212902
* IBM OpenAPI Terraform Generator Version: 3.97.0-0e90eab1-20241120-170029
*/

package partnercentersell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,26 @@ func TestAccIbmOnboardingCatalogDeploymentAllArgs(t *testing.T) {
activeUpdate := "false"
disabledUpdate := "false"
kindUpdate := "deployment"
overviewUiEn := "display_name"
overviewUiEnUpdate := "display_name_2"
rcCompatible := "true"
rcCompatibleUpdate := "false"
iamCompatible := "true"
iamCompatibleUpdate := "false"
deploymentBrokerName := "broker-petra-1"
deploymentBrokerNameUpdate := "broker-petra-2"
bulletTitleName := "title"
bulletTitleNameUpdate := "title-2"
mediaCaption := "Some random minecraft Video"
mediaCaptionUpdate := "Some random minecraft Video 2"

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheckPartnerCenterSell(t) },
Providers: acc.TestAccProviders,
CheckDestroy: testAccCheckIbmOnboardingCatalogDeploymentDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCheckIbmOnboardingCatalogDeploymentConfig(productID, catalogProductID, catalogPlanID, env, name, active, disabled, kind, objectId),
Config: testAccCheckIbmOnboardingCatalogDeploymentConfig(productID, catalogProductID, catalogPlanID, env, name, active, disabled, kind, objectId, overviewUiEn, rcCompatible, iamCompatible, deploymentBrokerName, bulletTitleName, mediaCaption),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckIbmOnboardingCatalogDeploymentExists("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", conf),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "product_id", productID),
Expand All @@ -103,10 +115,12 @@ func TestAccIbmOnboardingCatalogDeploymentAllArgs(t *testing.T) {
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "active", active),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "disabled", disabled),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "kind", kind),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "overview_ui.en.display_name", overviewUiEn),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "metadata.rc_compatible", rcCompatible),
),
},
resource.TestStep{
Config: testAccCheckIbmOnboardingCatalogDeploymentConfig(productID, catalogProductID, catalogPlanID, envUpdate, nameUpdate, activeUpdate, disabledUpdate, kindUpdate, objectId),
Config: testAccCheckIbmOnboardingCatalogDeploymentUpdateConfig(productID, catalogProductID, catalogPlanID, envUpdate, nameUpdate, activeUpdate, disabledUpdate, kindUpdate, objectId, overviewUiEnUpdate, rcCompatibleUpdate, iamCompatibleUpdate, deploymentBrokerNameUpdate, bulletTitleNameUpdate, mediaCaptionUpdate),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "product_id", productID),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "catalog_product_id", catalogProductID),
Expand All @@ -116,6 +130,8 @@ func TestAccIbmOnboardingCatalogDeploymentAllArgs(t *testing.T) {
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "active", activeUpdate),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "disabled", disabledUpdate),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "kind", kindUpdate),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "overview_ui.en.display_name", overviewUiEnUpdate),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_deployment.onboarding_catalog_deployment_instance", "metadata.rc_compatible", rcCompatibleUpdate),
),
},
resource.TestStep{
Expand Down Expand Up @@ -153,11 +169,12 @@ func testAccCheckIbmOnboardingCatalogDeploymentConfigBasic(productID string, cat
}
rc_compatible = false
}
}
`, productID, catalogProductID, catalogPlanID, name, active, disabled, kind, objectId)
}

func testAccCheckIbmOnboardingCatalogDeploymentConfig(productID string, catalogProductID string, catalogPlanID string, env string, name string, active string, disabled string, kind string, objectId string) string {
func testAccCheckIbmOnboardingCatalogDeploymentConfig(productID string, catalogProductID string, catalogPlanID string, env string, name string, active string, disabled string, kind string, objectId string, overviewUiEn string, rcCompatible string, iamCompatible string, deploymentBrokerName string, bulletTitleName string, mediaCaption string) string {
return fmt.Sprintf(`
resource "ibm_onboarding_catalog_deployment" "onboarding_catalog_deployment_instance" {
product_id = "%s"
Expand All @@ -171,7 +188,7 @@ func testAccCheckIbmOnboardingCatalogDeploymentConfig(productID string, catalogP
object_id = "%s"
overview_ui {
en {
display_name = "display_name"
display_name = "%s"
description = "description"
long_description = "long_description"
}
Expand All @@ -182,27 +199,106 @@ func testAccCheckIbmOnboardingCatalogDeploymentConfig(productID string, catalogP
email = "[email protected]"
}
metadata {
rc_compatible = true
rc_compatible = "%s"
service {
rc_provisionable = true
iam_compatible = true
iam_compatible = "%s"
}
deployment {
broker {
name = "%s"
guid = "guid"
}
location = "ams03"
location_url = "https://globalcatalog.test.cloud.ibm.com/api/v1/ams03"
target_crn = "crn:v1:staging:public::ams03:::environment:staging-ams03"
}
ui {
hidden = true
side_by_side_index = 1.0
strings {
en {
bullets {
title = "%s"
description = "some1"
}
media {
type = "youtube"
url = "https://www.youtube.com/embed/HtkpMgNFYtE"
caption = "%s"
}
}
}
}
}
}
`, productID, catalogProductID, catalogPlanID, env, name, active, disabled, kind, objectId, overviewUiEn, rcCompatible, iamCompatible, deploymentBrokerName, bulletTitleName, mediaCaption)
}

func testAccCheckIbmOnboardingCatalogDeploymentUpdateConfig(productID string, catalogProductID string, catalogPlanID string, env string, name string, active string, disabled string, kind string, objectId string, overviewUiEn string, rcCompatible string, iamCompatible string, deploymentBrokerName string, bulletTitleName string, mediaCaption string) string {
return fmt.Sprintf(`
resource "ibm_onboarding_catalog_deployment" "onboarding_catalog_deployment_instance" {
product_id = "%s"
catalog_product_id = "%s"
catalog_plan_id = "%s"
env = "%s"
name = "%s"
active = %s
disabled = %s
kind = "%s"
object_id = "%s"
overview_ui {
en {
display_name = "%s"
description = "description"
long_description = "long_description"
}
}
tags = ["sample", "moreSample"]
object_provider {
name = "name"
email = "[email protected]"
}
metadata {
rc_compatible = "%s"
service {
rc_provisionable = true
iam_compatible = "%s"
}
deployment {
broker {
name = "broker-petra-1"
name = "%s"
guid = "guid"
}
location = "ams03"
location_url = "https://globalcatalog.test.cloud.ibm.com/api/v1/ams03"
target_crn = "crn:v1:staging:public::ams03:::environment:staging-ams03"
}
ui {
strings {
en {
bullets {
title = "%s"
description = "some1"
}
bullets {
title = "newBullet"
description = "some1"
}
media {
type = "youtube"
url = "https://www.youtube.com/embed/HtkpMgNFYtE"
caption = "%s"
}
media {
type = "youtube"
url = "https://www.youtube.com/embed/HtkpMgNFYtE"
caption = "newMedia"
}
}
}
}
}
}
`, productID, catalogProductID, catalogPlanID, env, name, active, disabled, kind, objectId)
`, productID, catalogProductID, catalogPlanID, env, name, active, disabled, kind, objectId, overviewUiEn, rcCompatible, iamCompatible, deploymentBrokerName, bulletTitleName, mediaCaption)
}

func testAccCheckIbmOnboardingCatalogDeploymentExists(n string, obj partnercentersellv1.GlobalCatalogDeployment) resource.TestCheckFunc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Mozilla Public License v2.0

/*
* IBM OpenAPI Terraform Generator Version: 3.96.0-d6dec9d7-20241008-212902
* IBM OpenAPI Terraform Generator Version: 3.97.0-0e90eab1-20241120-170029
*/

package partnercentersell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,26 @@ func TestAccIbmOnboardingCatalogPlanAllArgs(t *testing.T) {
activeUpdate := "false"
disabledUpdate := "false"
kindUpdate := "plan"
overviewUiEn := "display_name"
overviewUiEnUpdate := "display_name_2"
rcCompatible := "true"
rcCompatibleUpdate := "false"
allowInternalUsers := "true"
allowInternalUsersUpdate := "false"
pricingType := "paid"
pricingTypeUpdate := "free"
bulletTitleName := "title"
bulletTitleNameUpdate := "title-2"
mediaCaption := "Some random minecraft Video"
mediaCaptionUpdate := "Some random minecraft Video 2"

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheckPartnerCenterSell(t) },
Providers: acc.TestAccProviders,
CheckDestroy: testAccCheckIbmOnboardingCatalogPlanDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCheckIbmOnboardingCatalogPlanConfig(productID, catalogProductID, env, name, active, disabled, kind, objectId),
Config: testAccCheckIbmOnboardingCatalogPlanConfig(productID, catalogProductID, env, name, active, disabled, kind, objectId, overviewUiEn, rcCompatible, pricingType, allowInternalUsers, bulletTitleName, mediaCaption),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckIbmOnboardingCatalogPlanExists("ibm_onboarding_catalog_plan.onboarding_catalog_plan_instance", conf),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_plan.onboarding_catalog_plan_instance", "product_id", productID),
Expand All @@ -101,7 +113,7 @@ func TestAccIbmOnboardingCatalogPlanAllArgs(t *testing.T) {
),
},
resource.TestStep{
Config: testAccCheckIbmOnboardingCatalogPlanConfig(productID, catalogProductID, envUpdate, nameUpdate, activeUpdate, disabledUpdate, kindUpdate, objectId),
Config: testAccCheckIbmOnboardingCatalogPlanUpdateConfig(productID, catalogProductID, envUpdate, nameUpdate, activeUpdate, disabledUpdate, kindUpdate, objectId, overviewUiEnUpdate, rcCompatibleUpdate, pricingTypeUpdate, allowInternalUsersUpdate, bulletTitleNameUpdate, mediaCaptionUpdate),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("ibm_onboarding_catalog_plan.onboarding_catalog_plan_instance", "product_id", productID),
resource.TestCheckResourceAttr("ibm_onboarding_catalog_plan.onboarding_catalog_plan_instance", "catalog_product_id", catalogProductID),
Expand Down Expand Up @@ -154,7 +166,7 @@ func testAccCheckIbmOnboardingCatalogPlanConfigBasic(productID string, catalogPr
`, productID, catalogProductID, name, active, disabled, kind, objectId)
}

func testAccCheckIbmOnboardingCatalogPlanConfig(productID string, catalogProductID string, env string, name string, active string, disabled string, kind string, objectId string) string {
func testAccCheckIbmOnboardingCatalogPlanConfig(productID string, catalogProductID string, env string, name string, active string, disabled string, kind string, objectId string, overviewUiEn string, rcCompatible string, pricingType string, allowInternalUsers string, bulletTitleName string, mediaCaption string) string {
return fmt.Sprintf(`
resource "ibm_onboarding_catalog_plan" "onboarding_catalog_plan_instance" {
Expand All @@ -168,7 +180,7 @@ func testAccCheckIbmOnboardingCatalogPlanConfig(productID string, catalogProduct
object_id = "%s"
overview_ui {
en {
display_name = "display_name"
display_name = "%s"
description = "description"
long_description = "long_description"
}
Expand All @@ -179,18 +191,96 @@ func testAccCheckIbmOnboardingCatalogPlanConfig(productID string, catalogProduct
email = "[email protected]"
}
metadata {
rc_compatible = false
rc_compatible = "%s"
pricing {
type = "paid"
type = "%s"
origin = "global_catalog"
}
plan {
allow_internal_users = true
allow_internal_users = "%s"
bindable = false
}
ui {
strings {
en {
bullets {
title = "%s"
description = "some1"
}
media {
type = "youtube"
url = "https://www.youtube.com/embed/HtkpMgNFYtE"
caption = "%s"
}
}
}
}
}
}
`, productID, catalogProductID, env, name, active, disabled, kind, objectId, overviewUiEn, rcCompatible, pricingType, allowInternalUsers, bulletTitleName, mediaCaption)
}

func testAccCheckIbmOnboardingCatalogPlanUpdateConfig(productID string, catalogProductID string, env string, name string, active string, disabled string, kind string, objectId string, overviewUiEn string, rcCompatible string, pricingType string, allowInternalUsers string, bulletTitleName string, mediaCaption string) string {
return fmt.Sprintf(`
resource "ibm_onboarding_catalog_plan" "onboarding_catalog_plan_instance" {
product_id = "%s"
catalog_product_id = "%s"
env = "%s"
name = "%s"
active = %s
disabled = %s
kind = "%s"
object_id = "%s"
overview_ui {
en {
display_name = "%s"
description = "description"
long_description = "long_description"
}
}
tags = ["tag"]
object_provider {
name = "name"
email = "[email protected]"
}
metadata {
rc_compatible = "%s"
pricing {
type = "%s"
origin = "global_catalog"
}
plan {
allow_internal_users = "%s"
bindable = false
}
ui {
strings {
en {
bullets {
title = "%s"
description = "some1"
}
bullets {
title = "newBullet"
description = "some1"
}
media {
type = "youtube"
url = "https://www.youtube.com/embed/HtkpMgNFYtE"
caption = "%s"
}
media {
type = "youtube"
url = "https://www.youtube.com/embed/HtkpMgNFYtE"
caption = "newMedia"
}
}
}
}
}
}
`, productID, catalogProductID, env, name, active, disabled, kind, objectId)
`, productID, catalogProductID, env, name, active, disabled, kind, objectId, overviewUiEn, rcCompatible, pricingType, allowInternalUsers, bulletTitleName, mediaCaption)
}

func testAccCheckIbmOnboardingCatalogPlanExists(n string, obj partnercentersellv1.GlobalCatalogPlan) resource.TestCheckFunc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Mozilla Public License v2.0

/*
* IBM OpenAPI Terraform Generator Version: 3.96.0-d6dec9d7-20241008-212902
* IBM OpenAPI Terraform Generator Version: 3.97.0-0e90eab1-20241120-170029
*/

package partnercentersell
Expand Down
Loading

0 comments on commit e95172e

Please sign in to comment.