Skip to content

Commit

Permalink
testing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickcping committed Nov 7, 2024
1 parent 3c6d605 commit b6e5f74
Show file tree
Hide file tree
Showing 11 changed files with 2,257 additions and 210 deletions.
408 changes: 404 additions & 4 deletions docs/resources/authorize_policy_management_policy.md

Large diffs are not rendered by default.

1,062 changes: 931 additions & 131 deletions docs/resources/authorize_policy_management_rule.md

Large diffs are not rendered by default.

455 changes: 451 additions & 4 deletions docs/resources/authorize_trust_framework_attribute.md

Large diffs are not rendered by default.

408 changes: 404 additions & 4 deletions docs/resources/authorize_trust_framework_condition.md

Large diffs are not rendered by default.

58 changes: 30 additions & 28 deletions internal/service/authorize/resource_trust_framework_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/patrickcping/pingone-go-sdk-v2/authorize"
Expand All @@ -25,20 +27,20 @@ import (
type TrustFrameworkAttributeResource serviceClientType

type trustFrameworkAttributeResourceModel struct {
Id pingonetypes.ResourceIDValue `tfsdk:"id"`
EnvironmentId pingonetypes.ResourceIDValue `tfsdk:"environment_id"`
DefaultValue types.String `tfsdk:"default_value"`
Description types.String `tfsdk:"description"`
Type types.String `tfsdk:"type"`
FullName types.String `tfsdk:"full_name"`
// ManagedEntity types.Object `tfsdk:"managed_entity"`
Name types.String `tfsdk:"name"`
Parent types.Object `tfsdk:"parent"`
Processor types.Object `tfsdk:"processor"`
RepetitionSource types.Object `tfsdk:"repetition_source"`
Resolvers types.List `tfsdk:"resolvers"`
ValueType types.Object `tfsdk:"value_type"`
Version types.String `tfsdk:"version"`
Id pingonetypes.ResourceIDValue `tfsdk:"id"`
EnvironmentId pingonetypes.ResourceIDValue `tfsdk:"environment_id"`
DefaultValue types.String `tfsdk:"default_value"`
Description types.String `tfsdk:"description"`
Type types.String `tfsdk:"type"`
FullName types.String `tfsdk:"full_name"`
ManagedEntity types.Object `tfsdk:"managed_entity"`
Name types.String `tfsdk:"name"`
Parent types.Object `tfsdk:"parent"`
Processor types.Object `tfsdk:"processor"`
RepetitionSource types.Object `tfsdk:"repetition_source"`
Resolvers types.List `tfsdk:"resolvers"`
ValueType types.Object `tfsdk:"value_type"`
Version types.String `tfsdk:"version"`
// ValueSchema types.String `tfsdk:"value_schema"`
}

Expand Down Expand Up @@ -72,9 +74,9 @@ func (r *TrustFrameworkAttributeResource) Schema(ctx context.Context, req resour
"A string that describes the resource type.",
).AllowedValuesEnum(authorize.AllowedEnumAuthorizeEditorDataDefinitionsAttributeDefinitionDTOTypeEnumValues)

// managedEntityDescription := framework.SchemaAttributeDescriptionFromMarkdown(
// "An object that specifies configuration settings for a system-assigned set of restrictions and metadata related to the resource.",
// )
managedEntityDescription := framework.SchemaAttributeDescriptionFromMarkdown(
"An object that specifies configuration settings for a system-assigned set of restrictions and metadata related to the resource.",
)

resp.Schema = schema.Schema{
// This description is used by the documentation generator and the language server.
Expand Down Expand Up @@ -106,15 +108,19 @@ func (r *TrustFrameworkAttributeResource) Schema(ctx context.Context, req resour
Description: typeDescription.Description,
MarkdownDescription: typeDescription.MarkdownDescription,
Computed: true,

PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},

// "managed_entity": schema.SingleNestedAttribute{ // TODO: DOC ERROR - Object Not in docs
// Description: managedEntityDescription.Description,
// MarkdownDescription: managedEntityDescription.MarkdownDescription,
// Computed: true,
"managed_entity": schema.SingleNestedAttribute{ // TODO: DOC ERROR - Object Not in docs
Description: managedEntityDescription.Description,
MarkdownDescription: managedEntityDescription.MarkdownDescription,
Computed: true,

// Attributes: managedEntityObjectSchemaAttributes(),
// },
Attributes: managedEntityObjectSchemaAttributes(),
},

"name": schema.StringAttribute{ // DONE
Description: framework.SchemaAttributeDescriptionFromMarkdown("A string that specifies a user-friendly authorization attribute name. The value must be unique.").Description,
Expand Down Expand Up @@ -449,10 +455,6 @@ func (p *trustFrameworkAttributeResourceModel) expand(ctx context.Context, updat
data.SetDescription(p.Description.ValueString())
}

// if !p.FullName.IsNull() && !p.FullName.IsUnknown() {
// data.SetFullName(p.FullName.ValueString())
// }

// if !p.ManagedEntity.IsNull() && !p.ManagedEntity.IsUnknown() {

// managedEntity, d := expandEditorManagedEntity(ctx, p.ManagedEntity)
Expand Down Expand Up @@ -549,7 +551,7 @@ func (p *trustFrameworkAttributeResourceModel) toState(ctx context.Context, apiO
p.Type = framework.EnumOkToTF(apiObject.GetTypeOk())
p.FullName = framework.StringOkToTF(apiObject.GetFullNameOk())

// p.ManagedEntity, d = editorManagedEntityOkToTF(apiObject.GetManagedEntityOk())
p.ManagedEntity, d = editorManagedEntityOkToTF(apiObject.GetManagedEntityOk())
diags.Append(d...)

p.Name = framework.StringOkToTF(apiObject.GetNameOk())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestAccTrustFrameworkAttribute_Full(t *testing.T) {
resource.TestCheckResourceAttr(resourceFullName, "default_value", "test"),
resource.TestCheckResourceAttr(resourceFullName, "processor.name", fmt.Sprintf("%s Test processor", name)),
resource.TestCheckResourceAttr(resourceFullName, "resolvers.#", "1"),
// resource.TestCheckResourceAttr(resourceFullName, "managed_entity", "1"),
resource.TestCheckNoResourceAttr(resourceFullName, "managed_entity"),
resource.TestMatchResourceAttr(resourceFullName, "repetition_source.id", verify.P1ResourceIDRegexpFullString),
resource.TestCheckResourceAttr(resourceFullName, "type", "ATTRIBUTE"),
resource.TestCheckResourceAttr(resourceFullName, "value_type.type", "STRING"),
Expand All @@ -140,7 +140,7 @@ func TestAccTrustFrameworkAttribute_Full(t *testing.T) {
resource.TestCheckNoResourceAttr(resourceFullName, "default_value"),
resource.TestCheckNoResourceAttr(resourceFullName, "processor"),
resource.TestCheckResourceAttr(resourceFullName, "resolvers.#", "0"),
// resource.TestCheckResourceAttr(resourceFullName, "managed_entity", "1"),
resource.TestCheckNoResourceAttr(resourceFullName, "managed_entity"),
resource.TestCheckNoResourceAttr(resourceFullName, "repetition_source"),
resource.TestCheckResourceAttr(resourceFullName, "type", "ATTRIBUTE"),
resource.TestCheckResourceAttr(resourceFullName, "value_type.type", "STRING"),
Expand Down Expand Up @@ -2358,18 +2358,14 @@ func testAccTrustFrameworkAttributeConfig_Resolver_User_Full(resourceName, name
return fmt.Sprintf(`
%[1]s
resource "pingone_population" "%[2]s" {
environment_id = data.pingone_environment.general_test.id
name = "%[3]s"
}
resource "pingone_user" "%[2]s" {
resource "pingone_authorize_trust_framework_attribute" "%[2]s-user" {
environment_id = data.pingone_environment.general_test.id
name = "%[3]s-user"
description = "Test attribute"
username = "%[3]s"
email = "%[3][email protected]"
population_id = pingone_population.%[2]s.id
value_type = {
type = "STRING"
}
}
resource "pingone_authorize_trust_framework_attribute" "%[2]s" {
Expand All @@ -2384,7 +2380,7 @@ resource "pingone_authorize_trust_framework_attribute" "%[2]s" {
type = "USER"
query = {
type = "USER_ID"
user_id = pingone_user.%[2]s.id
user_id = pingone_authorize_trust_framework_attribute.%[2]s-user.id
}
condition = {
Expand Down Expand Up @@ -2451,18 +2447,14 @@ func testAccTrustFrameworkAttributeConfig_Resolver_User_Min(resourceName, name s
return fmt.Sprintf(`
%[1]s
resource "pingone_population" "%[2]s" {
environment_id = data.pingone_environment.general_test.id
name = "%[3]s"
}
resource "pingone_user" "%[2]s" {
resource "pingone_authorize_trust_framework_attribute" "%[2]s-user" {
environment_id = data.pingone_environment.general_test.id
name = "%[3]s-user"
description = "Test attribute"
username = "%[3]s"
email = "%[3][email protected]"
population_id = pingone_population.%[2]s.id
value_type = {
type = "STRING"
}
}
resource "pingone_authorize_trust_framework_attribute" "%[2]s" {
Expand All @@ -2475,7 +2467,7 @@ resource "pingone_authorize_trust_framework_attribute" "%[2]s" {
type = "USER"
query = {
type = "USER_ID"
user_id = pingone_user.%[2]s.id
user_id = pingone_authorize_trust_framework_attribute.%[2]s-user.id
}
}
]
Expand Down
10 changes: 6 additions & 4 deletions internal/service/authorize/resource_trust_framework_condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/patrickcping/pingone-go-sdk-v2/authorize"
Expand Down Expand Up @@ -84,6 +86,10 @@ func (r *TrustFrameworkConditionResource) Schema(ctx context.Context, req resour
Description: typeDescription.Description,
MarkdownDescription: typeDescription.MarkdownDescription,
Computed: true,

PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},

"full_name": schema.StringAttribute{
Expand Down Expand Up @@ -395,10 +401,6 @@ func (p *trustFrameworkConditionResourceModel) expand(ctx context.Context, updat
data.SetDescription(p.Description.ValueString())
}

// if !p.FullName.IsNull() && !p.FullName.IsUnknown() {
// data.SetFullName(p.FullName.ValueString())
// }

if !p.Parent.IsNull() && !p.Parent.IsUnknown() {
parent, d := expandEditorParent(ctx, p.Parent)
diags.Append(d...)
Expand Down
10 changes: 6 additions & 4 deletions internal/service/authorize/resource_trust_framework_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/patrickcping/pingone-go-sdk-v2/authorize"
Expand Down Expand Up @@ -84,6 +86,10 @@ func (r *TrustFrameworkProcessorResource) Schema(ctx context.Context, req resour
Description: typeDescription.Description,
MarkdownDescription: typeDescription.MarkdownDescription,
Computed: true,

PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},

"full_name": schema.StringAttribute{
Expand Down Expand Up @@ -397,10 +403,6 @@ func (p *trustFrameworkProcessorResourceModel) expand(ctx context.Context, updat
data.SetDescription(p.Description.ValueString())
}

if !p.FullName.IsNull() && !p.FullName.IsUnknown() {
data.SetFullName(p.FullName.ValueString())
}

if !p.Parent.IsNull() && !p.Parent.IsUnknown() {
parent, d := expandEditorParent(ctx, p.Parent)
diags.Append(d...)
Expand Down
10 changes: 6 additions & 4 deletions internal/service/authorize/resource_trust_framework_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
Expand Down Expand Up @@ -354,6 +356,10 @@ func (r *TrustFrameworkServiceResource) Schema(ctx context.Context, req resource
Description: typeDescription.Description,
MarkdownDescription: typeDescription.MarkdownDescription,
Computed: true,

PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},

"cache_settings": schema.SingleNestedAttribute{ // DONE
Expand Down Expand Up @@ -1206,10 +1212,6 @@ func (p *trustFrameworkServiceResourceModel) expandCommon(ctx context.Context, u
authorize.EnumAuthorizeEditorDataDefinitionsServiceDefinitionDTOServiceType(p.ServiceType.ValueString()),
)

// if !p.FullName.IsNull() && !p.FullName.IsUnknown() {
// data.SetFullName(p.FullName.ValueString())
// }

if !p.Description.IsNull() && !p.Description.IsUnknown() {
data.SetDescription(p.Description.ValueString())
}
Expand Down
2 changes: 1 addition & 1 deletion internal/service/authorize/utils_editor_model_condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/pingidentity/terraform-provider-pingone/internal/utils"
)

const conditionNestedIterationMaxDepth = 3
const conditionNestedIterationMaxDepth = 4

var leafConditionTypes = []authorize.EnumAuthorizeEditorDataConditionDTOType{
"COMPARISON",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ func editorDataResolverQueryOkToTF(ctx context.Context, apiObject *authorize.Aut
return types.ObjectNull(editorDataResolverQueryTFObjectTypes), diags
}

attributeMap = editorDataResolverConvertEmptyValuesToTFNulls(attributeMap)
attributeMap = editorDataResolverQueryConvertEmptyValuesToTFNulls(attributeMap)

objValue, d := types.ObjectValue(editorDataResolverTFObjectTypes, attributeMap)
objValue, d := types.ObjectValue(editorDataResolverQueryTFObjectTypes, attributeMap)
diags.Append(d...)

return objValue, diags
Expand Down

0 comments on commit b6e5f74

Please sign in to comment.