From c70a8bc9acd90eae9ddd5a55f3800bcf087758f1 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 --- go.mod | 47 +++++++++++++++++++ .../application_app_role_resource.go | 6 ++- ...cation_oauth2_permission_scope_resource.go | 3 +- .../applications/validate/tokens_test.go | 4 +- vendor/modules.txt | 47 +++++++++++++++++++ 5 files changed, 102 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 17e358f527..af8e4bb026 100644 --- a/go.mod +++ b/go.mod @@ -3,14 +3,61 @@ module github.com/hashicorp/terraform-provider-azuread require ( github.com/Azure/azure-sdk-for-go v47.1.0+incompatible github.com/Azure/go-autorest/autorest v0.11.10 + github.com/Azure/go-autorest/autorest/adal v0.9.5 + github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 github.com/Azure/go-autorest/autorest/date v0.3.0 + github.com/Azure/go-autorest/autorest/to v0.4.0 + github.com/Azure/go-autorest/autorest/validation v0.3.0 + github.com/Azure/go-autorest/tracing v0.6.0 + github.com/apparentlymart/go-cidr v1.0.1 + github.com/apparentlymart/go-textseg/v13 v13.0.0 + github.com/aws/aws-sdk-go v1.25.3 + github.com/davecgh/go-spew v1.1.1 + github.com/golang/protobuf v1.4.3 github.com/google/uuid v1.1.2 + github.com/googleapis/gax-go/v2 v2.0.5 github.com/hashicorp/go-azure-helpers v0.13.1 + github.com/hashicorp/go-checkpoint v0.5.0 + github.com/hashicorp/go-cleanhttp v0.5.2 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 + github.com/hashicorp/go-getter v1.5.3 + github.com/hashicorp/go-hclog v0.15.0 + github.com/hashicorp/go-multierror v1.0.0 + github.com/hashicorp/go-plugin v1.4.0 github.com/hashicorp/go-uuid v1.0.2 + github.com/hashicorp/go-version v1.3.0 + github.com/hashicorp/hcl/v2 v2.3.0 + github.com/hashicorp/logutils v1.0.0 + github.com/hashicorp/terraform-exec v0.13.3 + github.com/hashicorp/terraform-json v0.10.0 + github.com/hashicorp/terraform-plugin-go v0.3.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.1 + github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af + github.com/klauspost/compress v1.11.2 github.com/manicminer/hamilton v0.13.0 + github.com/mattn/go-colorable v0.1.4 + github.com/mattn/go-isatty v0.0.10 + github.com/mitchellh/copystructure v1.0.0 + github.com/mitchellh/go-testing-interface v1.0.4 + github.com/mitchellh/mapstructure v1.1.2 + github.com/mitchellh/reflectwalk v1.0.1 github.com/sethvargo/go-password v0.2.0 + github.com/vmihailenco/msgpack v4.0.4+incompatible + github.com/zclconf/go-cty v1.8.2 + go.opencensus.io v0.22.4 + golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 + golang.org/x/mod v0.3.0 + golang.org/x/net v0.0.0-20210326060303-6b1517762897 + golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d + golang.org/x/sys v0.0.0-20210324051608-47abb6519492 + golang.org/x/text v0.3.5 + golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed + golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 + google.golang.org/api v0.29.0 + google.golang.org/appengine v1.6.7 + google.golang.org/genproto v0.0.0-20200711021454-869866162049 + google.golang.org/grpc v1.32.0 + google.golang.org/protobuf v1.25.0 ) go 1.16 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), diff --git a/vendor/modules.txt b/vendor/modules.txt index 4c3831fce3..4c325bdcfc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -19,29 +19,37 @@ github.com/Azure/go-autorest github.com/Azure/go-autorest/autorest github.com/Azure/go-autorest/autorest/azure # github.com/Azure/go-autorest/autorest/adal v0.9.5 +## explicit github.com/Azure/go-autorest/autorest/adal # github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 +## explicit github.com/Azure/go-autorest/autorest/azure/cli # github.com/Azure/go-autorest/autorest/date v0.3.0 ## explicit github.com/Azure/go-autorest/autorest/date # github.com/Azure/go-autorest/autorest/to v0.4.0 +## explicit github.com/Azure/go-autorest/autorest/to # github.com/Azure/go-autorest/autorest/validation v0.3.0 +## explicit github.com/Azure/go-autorest/autorest/validation # github.com/Azure/go-autorest/logger v0.2.0 github.com/Azure/go-autorest/logger # github.com/Azure/go-autorest/tracing v0.6.0 +## explicit github.com/Azure/go-autorest/tracing # github.com/agext/levenshtein v1.2.2 github.com/agext/levenshtein # github.com/apparentlymart/go-cidr v1.0.1 +## explicit github.com/apparentlymart/go-cidr/cidr # github.com/apparentlymart/go-textseg v1.0.0 github.com/apparentlymart/go-textseg/textseg # github.com/apparentlymart/go-textseg/v13 v13.0.0 +## explicit github.com/apparentlymart/go-textseg/v13/textseg # github.com/aws/aws-sdk-go v1.25.3 +## explicit github.com/aws/aws-sdk-go/aws github.com/aws/aws-sdk-go/aws/awserr github.com/aws/aws-sdk-go/aws/awsutil @@ -82,6 +90,7 @@ github.com/aws/aws-sdk-go/service/sts/stsiface # github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d github.com/bgentry/go-netrc/netrc # github.com/davecgh/go-spew v1.1.1 +## explicit github.com/davecgh/go-spew/spew # github.com/dimchansky/utfbom v1.1.0 github.com/dimchansky/utfbom @@ -92,6 +101,7 @@ github.com/form3tech-oss/jwt-go # github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e github.com/golang/groupcache/lru # github.com/golang/protobuf v1.4.3 +## explicit github.com/golang/protobuf/internal/gengogrpc github.com/golang/protobuf/proto github.com/golang/protobuf/protoc-gen-go @@ -105,6 +115,7 @@ github.com/golang/protobuf/ptypes/timestamp ## explicit github.com/google/uuid # github.com/googleapis/gax-go/v2 v2.0.5 +## explicit github.com/googleapis/gax-go/v2 # github.com/hashicorp/errwrap v1.0.0 github.com/hashicorp/errwrap @@ -114,8 +125,10 @@ github.com/hashicorp/go-azure-helpers/authentication github.com/hashicorp/go-azure-helpers/response github.com/hashicorp/go-azure-helpers/sender # github.com/hashicorp/go-checkpoint v0.5.0 +## explicit github.com/hashicorp/go-checkpoint # github.com/hashicorp/go-cleanhttp v0.5.2 +## explicit github.com/hashicorp/go-cleanhttp # github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 ## explicit @@ -126,13 +139,17 @@ github.com/hashicorp/go-cty/cty/json github.com/hashicorp/go-cty/cty/msgpack github.com/hashicorp/go-cty/cty/set # github.com/hashicorp/go-getter v1.5.3 +## explicit github.com/hashicorp/go-getter github.com/hashicorp/go-getter/helper/url # github.com/hashicorp/go-hclog v0.15.0 +## explicit github.com/hashicorp/go-hclog # github.com/hashicorp/go-multierror v1.0.0 +## explicit github.com/hashicorp/go-multierror # github.com/hashicorp/go-plugin v1.4.0 +## explicit github.com/hashicorp/go-plugin github.com/hashicorp/go-plugin/internal/plugin # github.com/hashicorp/go-safetemp v1.0.0 @@ -141,20 +158,26 @@ github.com/hashicorp/go-safetemp ## explicit github.com/hashicorp/go-uuid # github.com/hashicorp/go-version v1.3.0 +## explicit github.com/hashicorp/go-version # github.com/hashicorp/hcl/v2 v2.3.0 +## explicit github.com/hashicorp/hcl/v2 github.com/hashicorp/hcl/v2/ext/customdecode github.com/hashicorp/hcl/v2/hclsyntax # github.com/hashicorp/logutils v1.0.0 +## explicit github.com/hashicorp/logutils # github.com/hashicorp/terraform-exec v0.13.3 +## explicit github.com/hashicorp/terraform-exec/internal/version github.com/hashicorp/terraform-exec/tfexec github.com/hashicorp/terraform-exec/tfinstall # github.com/hashicorp/terraform-json v0.10.0 +## explicit github.com/hashicorp/terraform-json # github.com/hashicorp/terraform-plugin-go v0.3.0 +## explicit github.com/hashicorp/terraform-plugin-go/tfprotov5 github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/fromproto github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5 @@ -184,12 +207,14 @@ github.com/hashicorp/terraform-plugin-sdk/v2/terraform # github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d github.com/hashicorp/yamux # github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af +## explicit github.com/jmespath/go-jmespath # github.com/jstemmer/go-junit-report v0.9.1 github.com/jstemmer/go-junit-report github.com/jstemmer/go-junit-report/formatter github.com/jstemmer/go-junit-report/parser # github.com/klauspost/compress v1.11.2 +## explicit github.com/klauspost/compress/fse github.com/klauspost/compress/huff0 github.com/klauspost/compress/snappy @@ -204,20 +229,26 @@ github.com/manicminer/hamilton/internal/utils github.com/manicminer/hamilton/msgraph github.com/manicminer/hamilton/odata # github.com/mattn/go-colorable v0.1.4 +## explicit github.com/mattn/go-colorable # github.com/mattn/go-isatty v0.0.10 +## explicit github.com/mattn/go-isatty # github.com/mitchellh/copystructure v1.0.0 +## explicit github.com/mitchellh/copystructure # github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-homedir # github.com/mitchellh/go-testing-interface v1.0.4 +## explicit github.com/mitchellh/go-testing-interface # github.com/mitchellh/go-wordwrap v1.0.0 github.com/mitchellh/go-wordwrap # github.com/mitchellh/mapstructure v1.1.2 +## explicit github.com/mitchellh/mapstructure # github.com/mitchellh/reflectwalk v1.0.1 +## explicit github.com/mitchellh/reflectwalk # github.com/oklog/run v1.0.0 github.com/oklog/run @@ -230,9 +261,11 @@ github.com/ulikunitz/xz/internal/hash github.com/ulikunitz/xz/internal/xlog github.com/ulikunitz/xz/lzma # github.com/vmihailenco/msgpack v4.0.4+incompatible +## explicit github.com/vmihailenco/msgpack github.com/vmihailenco/msgpack/codes # github.com/zclconf/go-cty v1.8.2 +## explicit github.com/zclconf/go-cty/cty github.com/zclconf/go-cty/cty/convert github.com/zclconf/go-cty/cty/function @@ -241,6 +274,7 @@ github.com/zclconf/go-cty/cty/gocty github.com/zclconf/go-cty/cty/json github.com/zclconf/go-cty/cty/set # go.opencensus.io v0.22.4 +## explicit go.opencensus.io go.opencensus.io/internal go.opencensus.io/internal/tagencoding @@ -258,6 +292,7 @@ go.opencensus.io/trace/internal go.opencensus.io/trace/propagation go.opencensus.io/trace/tracestate # golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 +## explicit golang.org/x/crypto/blowfish golang.org/x/crypto/cast5 golang.org/x/crypto/chacha20 @@ -280,9 +315,11 @@ golang.org/x/crypto/ssh/internal/bcrypt_pbkdf golang.org/x/lint golang.org/x/lint/golint # golang.org/x/mod v0.3.0 +## explicit golang.org/x/mod/module golang.org/x/mod/semver # golang.org/x/net v0.0.0-20210326060303-6b1517762897 +## explicit golang.org/x/net/context golang.org/x/net/context/ctxhttp golang.org/x/net/http/httpguts @@ -292,21 +329,25 @@ golang.org/x/net/idna golang.org/x/net/internal/timeseries golang.org/x/net/trace # golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d +## explicit golang.org/x/oauth2 golang.org/x/oauth2/google golang.org/x/oauth2/internal golang.org/x/oauth2/jws golang.org/x/oauth2/jwt # golang.org/x/sys v0.0.0-20210324051608-47abb6519492 +## explicit golang.org/x/sys/cpu golang.org/x/sys/internal/unsafeheader golang.org/x/sys/unix # golang.org/x/text v0.3.5 +## explicit golang.org/x/text/secure/bidirule golang.org/x/text/transform golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm # golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed +## explicit golang.org/x/tools/cmd/goimports golang.org/x/tools/go/ast/astutil golang.org/x/tools/go/gcexportdata @@ -320,9 +361,11 @@ golang.org/x/tools/internal/gocommand golang.org/x/tools/internal/gopathwalk golang.org/x/tools/internal/imports # golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 +## explicit golang.org/x/xerrors golang.org/x/xerrors/internal # google.golang.org/api v0.29.0 +## explicit google.golang.org/api/googleapi google.golang.org/api/googleapi/transport google.golang.org/api/internal @@ -336,6 +379,7 @@ google.golang.org/api/transport/cert google.golang.org/api/transport/http google.golang.org/api/transport/http/internal/propagation # google.golang.org/appengine v1.6.7 +## explicit google.golang.org/appengine google.golang.org/appengine/datastore google.golang.org/appengine/datastore/internal/cloudkey @@ -350,12 +394,14 @@ google.golang.org/appengine/internal/remote_api google.golang.org/appengine/internal/urlfetch google.golang.org/appengine/urlfetch # google.golang.org/genproto v0.0.0-20200711021454-869866162049 +## explicit google.golang.org/genproto/googleapis/api/annotations google.golang.org/genproto/googleapis/iam/v1 google.golang.org/genproto/googleapis/rpc/code google.golang.org/genproto/googleapis/rpc/status google.golang.org/genproto/googleapis/type/expr # google.golang.org/grpc v1.32.0 +## explicit google.golang.org/grpc google.golang.org/grpc/attributes google.golang.org/grpc/backoff @@ -401,6 +447,7 @@ google.golang.org/grpc/stats google.golang.org/grpc/status google.golang.org/grpc/tap # google.golang.org/protobuf v1.25.0 +## explicit google.golang.org/protobuf/cmd/protoc-gen-go/internal_gengo google.golang.org/protobuf/compiler/protogen google.golang.org/protobuf/encoding/prototext