From ebaf2ab604a150437e5ea19c074e225982f82e9e Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 19 May 2021 22:21:23 +0100 Subject: [PATCH] Fix dependencies and broken unit test, add missing validation --- .../services/applications/application_app_role_resource.go | 6 ++++-- .../application_oauth2_permission_scope_resource.go | 3 ++- internal/services/applications/validate/tokens_test.go | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/services/applications/application_app_role_resource.go b/internal/services/applications/application_app_role_resource.go index 423066a674..0f0367c444 100644 --- a/internal/services/applications/application_app_role_resource.go +++ b/internal/services/applications/application_app_role_resource.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-provider-azuread/internal/clients" "github.com/hashicorp/terraform-provider-azuread/internal/services/applications/parse" + applicationsValidate "github.com/hashicorp/terraform-provider-azuread/internal/services/applications/validate" "github.com/hashicorp/terraform-provider-azuread/internal/tf" "github.com/hashicorp/terraform-provider-azuread/internal/validate" ) @@ -81,8 +82,9 @@ func applicationAppRoleResource() *schema.Resource { }, "value": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: applicationsValidate.RoleScopeClaimValue, }, }, } diff --git a/internal/services/applications/application_oauth2_permission_scope_resource.go b/internal/services/applications/application_oauth2_permission_scope_resource.go index 0a3f14071e..c6f9f784c0 100644 --- a/internal/services/applications/application_oauth2_permission_scope_resource.go +++ b/internal/services/applications/application_oauth2_permission_scope_resource.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-provider-azuread/internal/clients" "github.com/hashicorp/terraform-provider-azuread/internal/services/applications/parse" + applicationsValidate "github.com/hashicorp/terraform-provider-azuread/internal/services/applications/validate" "github.com/hashicorp/terraform-provider-azuread/internal/tf" "github.com/hashicorp/terraform-provider-azuread/internal/validate" ) @@ -101,7 +102,7 @@ func applicationOAuth2PermissionScopeResource() *schema.Resource { "value": { Type: schema.TypeString, Required: true, - ValidateDiagFunc: validate.NoEmptyStrings, + ValidateDiagFunc: applicationsValidate.RoleScopeClaimValue, }, }, } diff --git a/internal/services/applications/validate/tokens_test.go b/internal/services/applications/validate/tokens_test.go index 84dae2b85a..6613facdf8 100644 --- a/internal/services/applications/validate/tokens_test.go +++ b/internal/services/applications/validate/tokens_test.go @@ -36,8 +36,8 @@ func TestRoleScopeClaimValue(t *testing.T) { }, { Value: "", - TestName: "Invalid_MinLength", - ErrCount: 1, + TestName: "Valid_Empty", + ErrCount: 0, }, { Value: acctest.RandString(121),