diff --git a/go.mod b/go.mod index 0e06fd2..0f38146 100755 --- a/go.mod +++ b/go.mod @@ -4,57 +4,42 @@ go 1.17 require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 + github.com/hashicorp/terraform-plugin-docs v0.13.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.1 ) require ( - cloud.google.com/go v0.65.0 // indirect - cloud.google.com/go/storage v1.10.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.1.1 // indirect github.com/Masterminds/sprig/v3 v3.2.2 // indirect github.com/agext/levenshtein v1.2.2 // indirect - github.com/apparentlymart/go-cidr v1.1.0 // indirect github.com/apparentlymart/go-textseg/v12 v12.0.0 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect - github.com/aws/aws-sdk-go v1.37.0 // indirect - github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.13.0 // indirect - github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect github.com/golang/protobuf v1.4.2 // indirect github.com/google/uuid v1.3.0 // indirect - github.com/googleapis/gax-go/v2 v2.0.5 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.5.3 // indirect github.com/hashicorp/go-hclog v0.15.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.4.1 // indirect - github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/hc-install v0.4.0 // indirect github.com/hashicorp/hcl/v2 v2.8.2 // indirect - github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.17.2 // indirect github.com/hashicorp/terraform-json v0.14.0 // indirect - github.com/hashicorp/terraform-plugin-docs v0.13.0 // indirect github.com/hashicorp/terraform-plugin-go v0.3.0 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect github.com/huandu/xstrings v1.3.2 // indirect github.com/imdario/mergo v0.3.13 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/jstemmer/go-junit-report v0.9.1 // indirect - github.com/klauspost/compress v1.11.2 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mitchellh/cli v1.1.4 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.0.4 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect github.com/mitchellh/mapstructure v1.1.2 // indirect @@ -64,20 +49,12 @@ require ( github.com/russross/blackfriday v1.6.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect - github.com/ulikunitz/xz v0.5.8 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/zclconf/go-cty v1.10.0 // indirect - go.opencensus.io v0.22.4 // indirect golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect - golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect - golang.org/x/mod v0.3.0 // indirect golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect - golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect golang.org/x/text v0.3.7 // indirect - golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect - google.golang.org/api v0.34.0 // indirect google.golang.org/appengine v1.6.6 // indirect google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d // indirect google.golang.org/grpc v1.32.0 // indirect diff --git a/go.sum b/go.sum index eb3f7a0..b6d4233 100755 --- a/go.sum +++ b/go.sum @@ -12,9 +12,6 @@ cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bP cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.61.0/go.mod h1:XukKJg4Y7QsUu0Hxg3qQKUWR4VuWivmyMK2+rUyxAqw= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0 h1:Dg9iHVQfrhq82rUNu9ZxUDrJLaxFUe/HlCVaLyRruq8= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -31,7 +28,6 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0 h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -61,8 +57,6 @@ github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/apparentlymart/go-cidr v1.0.1/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= -github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU= -github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= @@ -78,9 +72,6 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.37.0 h1:GzFnhOIsrGyQ69s7VgqtrG2BG8v7X7vwB3Xpbd/DBBk= -github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= -github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= @@ -101,11 +92,12 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= @@ -123,7 +115,6 @@ github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3a github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -131,7 +122,6 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -155,14 +145,12 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0 h1:pMen7vLs8nvgEYhywH3KDWJIJTeEr2ULsVWHWYHQyBs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -177,9 +165,7 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -190,28 +176,23 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-getter v1.5.3 h1:NF5+zOlQegim+w/EUhSLh6QhXHmZMEeHLQzllkQ3ROU= github.com/hashicorp/go-getter v1.5.3/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v0.15.0 h1:qMuK0wxsoW4D0ddCCYwPSTm4KQv1X1ke3WmPWZ0Mvsk= github.com/hashicorp/go-hclog v0.15.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.3.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0= github.com/hashicorp/go-plugin v1.4.1 h1:6UltRQlLN9iZO513VveELp5xyaFxVD2+1OVylE+2E+w= github.com/hashicorp/go-plugin v1.4.1/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= -github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw= github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= @@ -223,13 +204,10 @@ github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+Tb github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8= github.com/hashicorp/hcl/v2 v2.8.2 h1:wmFle3D1vu0okesm8BTLVDyJ6/OL9DCLUwn0b2OptiY= github.com/hashicorp/hcl/v2 v2.8.2/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY= -github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.14.0 h1:UQoUcxKTZZXhyyK68Cwn4mApT4mnFPmEXPiqaHL9r+w= github.com/hashicorp/terraform-exec v0.14.0/go.mod h1:qrAASDq28KZiMPDnQ02sFS9udcqEkRly002EA2izXTA= github.com/hashicorp/terraform-exec v0.17.2 h1:EU7i3Fh7vDUI9nNRdMATCEfnm9axzTnad8zszYZ73Go= github.com/hashicorp/terraform-exec v0.17.2/go.mod h1:tuIbsL2l4MlwwIZx9HPM+LOV9vVyEfBYu2GsO1uH3/8= -github.com/hashicorp/terraform-json v0.12.0 h1:8czPgEEWWPROStjkWPUnTQDXmpmZPlkQAwYYLETaTvw= github.com/hashicorp/terraform-json v0.12.0/go.mod h1:pmbq9o4EuL43db5+0ogX10Yofv1nozM+wskr/bGFJpI= github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s= github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= @@ -247,7 +225,6 @@ github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= @@ -258,22 +235,17 @@ github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZ github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ= github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -283,7 +255,6 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= @@ -291,7 +262,6 @@ github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= @@ -332,6 +302,8 @@ github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXq github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= @@ -356,7 +328,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ= github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= @@ -368,10 +339,8 @@ github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6e github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.8.4 h1:pwhhz5P+Fjxse7S7UriBrMu6AUJSZM5pKqGem1PjGAs= github.com/zclconf/go-cty v1.8.4/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= @@ -380,7 +349,6 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -392,7 +360,6 @@ golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= @@ -418,7 +385,6 @@ golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -427,7 +393,6 @@ golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -456,11 +421,7 @@ golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210326060303-6b1517762897 h1:KrsHThm5nFk34YtATK1LsThyGhGbGe1olrte/HInHvs= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -469,8 +430,6 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 h1:ld7aEMNHoBnnDAX15v1T6z31v8HwR2A9FYOuAhWqkwc= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -479,7 +438,6 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -510,28 +468,24 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 h1:RX8C8PRZc2hTIod4ds8ij+/4RQX3AqhYj3uOHmyaz4E= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -575,17 +529,9 @@ golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb h1:KVWk3RW1AZlxWum4tYqegLgwJHb5oouozcGM8HfNQaw= -golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -601,9 +547,6 @@ google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.34.0 h1:k40adF3uR+6x/+hO5Dh4ZFUqFp67vxvbpafFiJxl10A= -google.golang.org/api v0.34.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -639,9 +582,6 @@ google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1m google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d h1:92D1fum1bJLKSdr11OJ+54YeCMCGYIygTA7R/YZxH5M= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= @@ -656,8 +596,6 @@ google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.32.0 h1:zWTV+LMdc3kaiJMSTOFz2UgSBgx8RNQoTGiZu3fR9S0= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -683,11 +621,9 @@ gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/provider/data_source_custom_rule_test.go b/internal/provider/data_source_custom_rule_test.go index 941a7f6..aae0d75 100644 --- a/internal/provider/data_source_custom_rule_test.go +++ b/internal/provider/data_source_custom_rule_test.go @@ -1,34 +1,34 @@ package provider -import ( - "fmt" - "testing" +// import ( +// "fmt" +// "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// ) -func TestAccDsCustomRule(t *testing.T) { - name := fmt.Sprintf("tf%s", acctest.RandString(6)) +// func TestAccDsCustomRule(t *testing.T) { +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccDsCustomRule(name), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrSet("data.prismacloudcompute_custom_rule.test", "name"), - ), - }, - }, - }) -} +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// Steps: []resource.TestStep{ +// { +// Config: testAccDsCustomRule(name), +// Check: resource.ComposeAggregateTestCheckFunc( +// resource.TestCheckResourceAttrSet("data.prismacloudcompute_custom_rule.test", "name"), +// ), +// }, +// }, +// }) +// } -func testAccDsCustomRule(name string) string { - return fmt.Sprintf(` - data "prismacloudcompute_custom_rule" "test" { - name = %q - } - `, name) -} +// func testAccDsCustomRule(name string) string { +// return fmt.Sprintf(` +// data "prismacloudcompute_custom_rule" "test" { +// name = %q +// } +// `, name) +// } diff --git a/internal/provider/resource_alertprofile_test.go b/internal/provider/resource_alertprofile_test.go index 37bd9f5..1786fb4 100644 --- a/internal/provider/resource_alertprofile_test.go +++ b/internal/provider/resource_alertprofile_test.go @@ -1,165 +1,165 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/alertprofile" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccAlertprofileConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccAlertprofileConfig") - var o alertprofile.Alertprofile - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccAlertprofileDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAlertprofileConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), - testAccCheckAlertprofileAttributes(&o, name), - ), - }, - { - Config: testAccAlertprofileConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), - testAccCheckAlertprofileAttributes(&o, name), - ), - }, - }, - }) -} - -func TestAccAlertprofileNetwork(t *testing.T) { - var o alertprofile.Alertprofile - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccAlertprofileDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAlertprofileConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), - testAccCheckAlertprofileAttributes(&o, name), - ), - }, - { - Config: testAccAlertprofileConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), - testAccCheckAlertprofileAttributes(&o, name), - ), - }, - }, - }) -} - -func TestAccAlertprofileAuditEvent(t *testing.T) { - var o alertprofile.Alertprofile - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccAlertprofileDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAlertprofileConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), - testAccCheckAlertprofileAttributes(&o, name), - ), - }, - { - Config: testAccAlertprofileConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), - testAccCheckAlertprofileAttributes(&o, name), - ), - }, - }, - }) -} - -func testAccCheckAlertprofileExists(n string, o *alertprofile.Alertprofile) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.Name) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object Name is not set") - } - - client := testAccProvider.Meta().(*api.Client) - id := rs.Primary.ID - lo, err := alertprofile.GetAlertprofile(*client, id) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - o = lo - - return nil - } -} - -func testAccCheckAlertprofileAttributes(o *alertprofile.Alertprofile, name string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.Name != name { - return fmt.Errorf("\n\nName is %s, expected %s", o.Name, name) - } else { - fmt.Printf("\n\nName is %s", o.Name) - } - return nil - } -} - -func testAccAlertprofileDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_alertprofile" { - continue - } - - if rs.Primary.ID != "" { - id := rs.Primary.ID - if err := alertprofile.DeleteAlertprofile(*client, id); err == nil { - return fmt.Errorf("Object %q still exists", id) - } - } - return nil - } - - return nil -} - -func testAccAlertprofileConfig(name string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_alertprofiles" "test" { - name = %q -}`, name)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/alertprofile" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccAlertprofileConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccAlertprofileConfig") +// var o alertprofile.Alertprofile +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccAlertprofileDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccAlertprofileConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), +// testAccCheckAlertprofileAttributes(&o, name), +// ), +// }, +// { +// Config: testAccAlertprofileConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), +// testAccCheckAlertprofileAttributes(&o, name), +// ), +// }, +// }, +// }) +// } + +// func TestAccAlertprofileNetwork(t *testing.T) { +// var o alertprofile.Alertprofile +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccAlertprofileDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccAlertprofileConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), +// testAccCheckAlertprofileAttributes(&o, name), +// ), +// }, +// { +// Config: testAccAlertprofileConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), +// testAccCheckAlertprofileAttributes(&o, name), +// ), +// }, +// }, +// }) +// } + +// func TestAccAlertprofileAuditEvent(t *testing.T) { +// var o alertprofile.Alertprofile +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccAlertprofileDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccAlertprofileConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), +// testAccCheckAlertprofileAttributes(&o, name), +// ), +// }, +// { +// Config: testAccAlertprofileConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckAlertprofileExists("prismacloudcompute_alertprofile.test", &o), +// testAccCheckAlertprofileAttributes(&o, name), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckAlertprofileExists(n string, o *alertprofile.Alertprofile) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.Name) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object Name is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// id := rs.Primary.ID +// lo, err := alertprofile.GetAlertprofile(*client, id) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// o = lo + +// return nil +// } +// } + +// func testAccCheckAlertprofileAttributes(o *alertprofile.Alertprofile, name string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.Name != name { +// return fmt.Errorf("\n\nName is %s, expected %s", o.Name, name) +// } else { +// fmt.Printf("\n\nName is %s", o.Name) +// } +// return nil +// } +// } + +// func testAccAlertprofileDestroy(s *terraform.State) error { +// client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_alertprofile" { +// continue +// } + +// if rs.Primary.ID != "" { +// id := rs.Primary.ID +// if err := alertprofile.DeleteAlertprofile(*client, id); err == nil { +// return fmt.Errorf("Object %q still exists", id) +// } +// } +// return nil +// } + +// return nil +// } + +// func testAccAlertprofileConfig(name string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_alertprofiles" "test" { +// name = %q +// }`, name)) + +// return buf.String() +// } diff --git a/internal/provider/resource_collection_test.go b/internal/provider/resource_collection_test.go index adc3fd5..ecc6be3 100755 --- a/internal/provider/resource_collection_test.go +++ b/internal/provider/resource_collection_test.go @@ -1,174 +1,174 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/collection" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccCollectionConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccCollectionConfig") - var o collection.Collection - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCollectionDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCollectionConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), - testAccCheckCollectionAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccCollectionConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), - testAccCheckCollectionAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func TestAccCollectionNetwork(t *testing.T) { - var o collection.Collection - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCollectionDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCollectionConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), - testAccCheckCollectionAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccCollectionConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), - testAccCheckCollectionAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func TestAccCollectionAuditEvent(t *testing.T) { - var o collection.Collection - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCollectionDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCollectionConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), - testAccCheckCollectionAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccCollectionConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), - testAccCheckCollectionAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func testAccCheckCollectionExists(n string, o *collection.Collection) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.Name) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Name is not set") - } - - client := testAccProvider.Meta().(*api.Client) - name := rs.Primary.ID - lo, err := collection.Get(*client, name) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - o = lo - - return nil - } -} - -func testAccCheckCollectionAttributes(o *collection.Collection, name string, description string, color string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.Name != name { - return fmt.Errorf("\n\nName is %s, expected %s", o.Name, name) - } else { - fmt.Printf("\n\nName is %s", o.Name) - } - - if o.Description != description { - return fmt.Errorf("Description is %s, expected %s", o.Description, description) - } - - if o.Color != color { - return fmt.Errorf("Color type is %q, expected %q", o.Color, color) - } - - return nil - } -} - -func testAccCollectionDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_collection" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := collection.Delete(*client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - - return nil -} - -func testAccCollectionConfig(name string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_collections" "test" { - name = %q -}`, name)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/collection" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccCollectionConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccCollectionConfig") +// var o collection.Collection +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCollectionDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCollectionConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), +// testAccCheckCollectionAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccCollectionConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), +// testAccCheckCollectionAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func TestAccCollectionNetwork(t *testing.T) { +// var o collection.Collection +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCollectionDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCollectionConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), +// testAccCheckCollectionAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccCollectionConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), +// testAccCheckCollectionAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func TestAccCollectionAuditEvent(t *testing.T) { +// var o collection.Collection +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCollectionDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCollectionConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), +// testAccCheckCollectionAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccCollectionConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCollectionExists("prismacloudcompute_collection.test", &o), +// testAccCheckCollectionAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckCollectionExists(n string, o *collection.Collection) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.Name) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Name is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// name := rs.Primary.ID +// lo, err := collection.Get(*client, name) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// o = lo + +// return nil +// } +// } + +// func testAccCheckCollectionAttributes(o *collection.Collection, name string, description string, color string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.Name != name { +// return fmt.Errorf("\n\nName is %s, expected %s", o.Name, name) +// } else { +// fmt.Printf("\n\nName is %s", o.Name) +// } + +// if o.Description != description { +// return fmt.Errorf("Description is %s, expected %s", o.Description, description) +// } + +// if o.Color != color { +// return fmt.Errorf("Color type is %q, expected %q", o.Color, color) +// } + +// return nil +// } +// } + +// func testAccCollectionDestroy(s *terraform.State) error { +// client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_collection" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := collection.Delete(*client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } + +// return nil +// } + +// func testAccCollectionConfig(name string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_collections" "test" { +// name = %q +// }`, name)) + +// return buf.String() +// } diff --git a/internal/provider/resource_credentials_test.go b/internal/provider/resource_credentials_test.go index 4d6202c..3d687ba 100644 --- a/internal/provider/resource_credentials_test.go +++ b/internal/provider/resource_credentials_test.go @@ -1,166 +1,166 @@ package provider -import ( - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestCredentialsConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccCredentialsConfig") - var o group.Group - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCredentialsDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCredentialsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), - testAccCheckCredentialsAttributes(&o, id, true), - ), - }, - { - Config: testAccCredentialsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), - testAccCheckCredentialsAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestCredentialsNetwork(t *testing.T) { - var o group.Group - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCredentialsDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCredentialsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), - testAccCheckCredentialsAttributes(&o, id, true), - ), - }, - { - Config: testAccCredentialsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), - testAccCheckCredentialsAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestCredentialsAuditEvent(t *testing.T) { - var o group.Group - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCredentialsDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCredentialsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), - testAccCheckCredentialsAttributes(&o, id, true), - ), - }, - { - Config: testAccCredentialsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), - testAccCheckCredentialsAttributes(&o, id, true), - ), - }, - }, - }) -} - -func testCredentialsExists(n string, o *group.Group) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.GroupId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := Credentials.Get(*client) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -// func testCredentialsAttributes(o *group.Group, id string, learningDisabled bool) resource.TestCheckFunc { -// return func(s *terraform.State) error { -// if o.GroupId != id { -// return fmt.Errorf("\n\nGroupId is %s, expected %s", o.GroupId, id) -// } else { -// fmt.Printf("\n\nName is %s", o.GroupId) -// } - -// if o.LearningDisabled != learningDisabled { -// return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) -// } - -// return nil -// } +// import ( +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestCredentialsConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccCredentialsConfig") +// var o group.Group +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCredentialsDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCredentialsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), +// testAccCheckCredentialsAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccCredentialsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), +// testAccCheckCredentialsAttributes(&o, id, true), +// ), +// }, +// }, +// }) // } -// func testCredentialsDestroy(s *terraform.State) error { -// /* client := testAccProvider.Meta().(*api.Client) +// func TestCredentialsNetwork(t *testing.T) { +// var o group.Group +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCredentialsDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCredentialsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), +// testAccCheckCredentialsAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccCredentialsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), +// testAccCheckCredentialsAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } -// for _, rs := range s.RootModule().Resources { +// func TestCredentialsAuditEvent(t *testing.T) { +// var o group.Group +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCredentialsDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCredentialsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), +// testAccCheckCredentialsAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccCredentialsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCredentialsExists("prismacloudcompute_credentials.test", &o), +// testAccCheckCredentialsAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } -// if rs.Type != "prismacloudcompute_credentials" { -// continue -// } +// func testCredentialsExists(n string, o *group.Group) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.GroupId) -// if rs.Primary.ID != "" { -// name := rs.Primary.ID -// if err := group.Delete(client, name); err == nil { -// return fmt.Errorf("Object %q still exists", name) -// } -// } -// return nil +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) // } -// */ -// return nil -// } -// func testCredentialsConfig(id string) string { -// var buf bytes.Buffer -// buf.Grow(500) +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } -// buf.WriteString(fmt.Sprintf(` -// resource "prismacloudcompute_credentials" "test" { -// name = %q -// }`, id)) +// client := testAccProvider.Meta().(*api.Client) +// lo, err := Credentials.Get(*client) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo -// return buf.String() +// return nil +// } // } + +// // func testCredentialsAttributes(o *group.Group, id string, learningDisabled bool) resource.TestCheckFunc { +// // return func(s *terraform.State) error { +// // if o.GroupId != id { +// // return fmt.Errorf("\n\nGroupId is %s, expected %s", o.GroupId, id) +// // } else { +// // fmt.Printf("\n\nName is %s", o.GroupId) +// // } + +// // if o.LearningDisabled != learningDisabled { +// // return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) +// // } + +// // return nil +// // } +// // } + +// // func testCredentialsDestroy(s *terraform.State) error { +// // /* client := testAccProvider.Meta().(*api.Client) + +// // for _, rs := range s.RootModule().Resources { + +// // if rs.Type != "prismacloudcompute_credentials" { +// // continue +// // } + +// // if rs.Primary.ID != "" { +// // name := rs.Primary.ID +// // if err := group.Delete(client, name); err == nil { +// // return fmt.Errorf("Object %q still exists", name) +// // } +// // } +// // return nil +// // } +// // */ +// // return nil +// // } + +// // func testCredentialsConfig(id string) string { +// // var buf bytes.Buffer +// // buf.Grow(500) + +// // buf.WriteString(fmt.Sprintf(` +// // resource "prismacloudcompute_credentials" "test" { +// // name = %q +// // }`, id)) + +// // return buf.String() +// // } diff --git a/internal/provider/resource_custom_compliance_test.go b/internal/provider/resource_custom_compliance_test.go index 011145b..fdbdea9 100644 --- a/internal/provider/resource_custom_compliance_test.go +++ b/internal/provider/resource_custom_compliance_test.go @@ -1,166 +1,166 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccCustomComplianceConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccCustomComplianceConfig") - var o policy.CustomCompliance - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCustomComplianceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCustomComplianceConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), - testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccCustomComplianceConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), - testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func TestAccCustomComplianceNetwork(t *testing.T) { - var o policy.CustomCompliance - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCustomComplianceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCustomComplianceConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), - testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccCustomComplianceConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), - testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func TestAccCustomComplianceAuditEvent(t *testing.T) { - var o policy.CustomCompliance - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCustomComplianceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCustomComplianceConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), - testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccCustomComplianceConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), - testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func testAccCheckCustomComplianceExists(n string, o *policy.CustomCompliance) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.Name) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Name is not set") - } - - client := testAccProvider.Meta().(*api.Client) - name := rs.Primary.ID - lo, err := policy.Get(*client, name) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - o = lo - - return nil - } -} - -func testAccCheckCustomComplianceAttributes(o *policy.CustomCompliance, name string, description string, color string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.Name != name { - return fmt.Errorf("\n\nName is %s, expected %s", o.Name, name) - } else { - fmt.Printf("\n\nName is %s", o.Name) - } - - return nil - } -} - -func testAccCustomComplianceDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_custom_Compliance" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(*client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - - return nil -} - -func testAccCustomComplianceConfig(name string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_custom_Compliances" "test" { - name = %q -}`, name)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccCustomComplianceConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccCustomComplianceConfig") +// var o policy.CustomCompliance +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCustomComplianceDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCustomComplianceConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), +// testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccCustomComplianceConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), +// testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func TestAccCustomComplianceNetwork(t *testing.T) { +// var o policy.CustomCompliance +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCustomComplianceDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCustomComplianceConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), +// testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccCustomComplianceConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), +// testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func TestAccCustomComplianceAuditEvent(t *testing.T) { +// var o policy.CustomCompliance +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCustomComplianceDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCustomComplianceConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), +// testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccCustomComplianceConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomComplianceExists("prismacloudcompute_custom_Compliance.test", &o), +// testAccCheckCustomComplianceAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckCustomComplianceExists(n string, o *policy.CustomCompliance) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.Name) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Name is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// name := rs.Primary.ID +// lo, err := policy.Get(*client, name) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// o = lo + +// return nil +// } +// } + +// func testAccCheckCustomComplianceAttributes(o *policy.CustomCompliance, name string, description string, color string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.Name != name { +// return fmt.Errorf("\n\nName is %s, expected %s", o.Name, name) +// } else { +// fmt.Printf("\n\nName is %s", o.Name) +// } + +// return nil +// } +// } + +// func testAccCustomComplianceDestroy(s *terraform.State) error { +// client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_custom_Compliance" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(*client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } + +// return nil +// } + +// func testAccCustomComplianceConfig(name string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_custom_Compliances" "test" { +// name = %q +// }`, name)) + +// return buf.String() +// } diff --git a/internal/provider/resource_custom_rule_test.go b/internal/provider/resource_custom_rule_test.go index 7b6dcf6..3c5a6db 100755 --- a/internal/provider/resource_custom_rule_test.go +++ b/internal/provider/resource_custom_rule_test.go @@ -1,174 +1,174 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/rule" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccCustomRuleConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccCustomRuleConfig") - var o rule.CustomRule - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCustomRuleDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCustomRuleConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), - testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccCustomRuleConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), - testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func TestAccCustomRuleNetwork(t *testing.T) { - var o rule.CustomRule - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCustomRuleDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCustomRuleConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), - testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccCustomRuleConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), - testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func TestAccCustomRuleAuditEvent(t *testing.T) { - var o rule.CustomRule - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCustomRuleDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCustomRuleConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), - testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccCustomRuleConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), - testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func testAccCheckCustomRuleExists(n string, o *rule.CustomRule) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.Name) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Name is not set") - } - - client := testAccProvider.Meta().(*api.Client) - name := rs.Primary.ID - lo, err := rule.Get(*client, name) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - o = lo - - return nil - } -} - -func testAccCheckCustomRuleAttributes(o *rule.CustomRule, name string, description string, color string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.Name != name { - return fmt.Errorf("\n\nName is %s, expected %s", o.Name, name) - } else { - fmt.Printf("\n\nName is %s", o.Name) - } - - if o.Description != description { - return fmt.Errorf("Description is %s, expected %s", o.Description, description) - } - - if o.Color != color { - return fmt.Errorf("Color type is %q, expected %q", o.Color, color) - } - - return nil - } -} - -func testAccCustomRuleDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_custom_rule" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := rule.Delete(*client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - - return nil -} - -func testAccCustomRuleConfig(name string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_custom_rules" "test" { - name = %q -}`, name)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/rule" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccCustomRuleConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccCustomRuleConfig") +// var o rule.CustomRule +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCustomRuleDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCustomRuleConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), +// testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccCustomRuleConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), +// testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func TestAccCustomRuleNetwork(t *testing.T) { +// var o rule.CustomRule +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCustomRuleDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCustomRuleConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), +// testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccCustomRuleConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), +// testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func TestAccCustomRuleAuditEvent(t *testing.T) { +// var o rule.CustomRule +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccCustomRuleDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccCustomRuleConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), +// testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccCustomRuleConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckCustomRuleExists("prismacloudcompute_custom_rule.test", &o), +// testAccCheckCustomRuleAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckCustomRuleExists(n string, o *rule.CustomRule) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.Name) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Name is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// name := rs.Primary.ID +// lo, err := rule.Get(*client, name) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// o = lo + +// return nil +// } +// } + +// func testAccCheckCustomRuleAttributes(o *rule.CustomRule, name string, description string, color string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.Name != name { +// return fmt.Errorf("\n\nName is %s, expected %s", o.Name, name) +// } else { +// fmt.Printf("\n\nName is %s", o.Name) +// } + +// if o.Description != description { +// return fmt.Errorf("Description is %s, expected %s", o.Description, description) +// } + +// if o.Color != color { +// return fmt.Errorf("Color type is %q, expected %q", o.Color, color) +// } + +// return nil +// } +// } + +// func testAccCustomRuleDestroy(s *terraform.State) error { +// client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_custom_rule" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := rule.Delete(*client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } + +// return nil +// } + +// func testAccCustomRuleConfig(name string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_custom_rules" "test" { +// name = %q +// }`, name)) + +// return buf.String() +// } diff --git a/internal/provider/resource_groups_test.go b/internal/provider/resource_groups_test.go index ca79cce..0b07dd9 100644 --- a/internal/provider/resource_groups_test.go +++ b/internal/provider/resource_groups_test.go @@ -1,166 +1,156 @@ package provider -import ( - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestGroupsConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccGroupsConfig") - var o group.Group - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccGroupsDestroy, - Steps: []resource.TestStep{ - { - Config: testAccGroupsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), - testAccCheckGroupsAttributes(&o, id, true), - ), - }, - { - Config: testAccGroupsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), - testAccCheckGroupsAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestGroupsNetwork(t *testing.T) { - var o group.Group - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccGroupsDestroy, - Steps: []resource.TestStep{ - { - Config: testAccGroupsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), - testAccCheckGroupsAttributes(&o, id, true), - ), - }, - { - Config: testAccGroupsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), - testAccCheckGroupsAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestGroupsAuditEvent(t *testing.T) { - var o group.Group - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccGroupsDestroy, - Steps: []resource.TestStep{ - { - Config: testAccGroupsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), - testAccCheckGroupsAttributes(&o, id, true), - ), - }, - { - Config: testAccGroupsConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), - testAccCheckGroupsAttributes(&o, id, true), - ), - }, - }, - }) -} - -func testGroupsExists(n string, o *group.Group) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.GroupId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := groups.Get(*client) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -// func testGroupsAttributes(o *group.Group, id string, learningDisabled bool) resource.TestCheckFunc { -// return func(s *terraform.State) error { -// if o.GroupId != id { -// return fmt.Errorf("\n\nGroupId is %s, expected %s", o.GroupId, id) -// } else { -// fmt.Printf("\n\nName is %s", o.GroupId) -// } - -// if o.LearningDisabled != learningDisabled { -// return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) -// } - -// return nil -// } +// func TestGroupsConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccGroupsConfig") +// var o group.Group +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccGroupsDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccGroupsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), +// testAccCheckGroupsAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccGroupsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), +// testAccCheckGroupsAttributes(&o, id, true), +// ), +// }, +// }, +// }) // } -// func testGroupsDestroy(s *terraform.State) error { -// /* client := testAccProvider.Meta().(*api.Client) +// func TestGroupsNetwork(t *testing.T) { +// var o group.Group +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccGroupsDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccGroupsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), +// testAccCheckGroupsAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccGroupsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), +// testAccCheckGroupsAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } -// for _, rs := range s.RootModule().Resources { +// func TestGroupsAuditEvent(t *testing.T) { +// var o group.Group +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccGroupsDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccGroupsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), +// testAccCheckGroupsAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccGroupsConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckGroupsExists("prismacloudcompute_groups.test", &o), +// testAccCheckGroupsAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } -// if rs.Type != "prismacloudcompute_groups" { -// continue -// } +// func testGroupsExists(n string, o *group.Group) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.GroupId) -// if rs.Primary.ID != "" { -// name := rs.Primary.ID -// if err := group.Delete(client, name); err == nil { -// return fmt.Errorf("Object %q still exists", name) -// } -// } -// return nil +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) // } -// */ -// return nil -// } -// func testGroupsConfig(id string) string { -// var buf bytes.Buffer -// buf.Grow(500) +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } -// buf.WriteString(fmt.Sprintf(` -// resource "prismacloudcompute_groups" "test" { -// name = %q -// }`, id)) +// client := testAccProvider.Meta().(*api.Client) +// lo, err := groups.Get(*client) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo -// return buf.String() +// return nil +// } // } + +// // func testGroupsAttributes(o *group.Group, id string, learningDisabled bool) resource.TestCheckFunc { +// // return func(s *terraform.State) error { +// // if o.GroupId != id { +// // return fmt.Errorf("\n\nGroupId is %s, expected %s", o.GroupId, id) +// // } else { +// // fmt.Printf("\n\nName is %s", o.GroupId) +// // } + +// // if o.LearningDisabled != learningDisabled { +// // return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) +// // } + +// // return nil +// // } +// // } + +// // func testGroupsDestroy(s *terraform.State) error { +// // /* client := testAccProvider.Meta().(*api.Client) + +// // for _, rs := range s.RootModule().Resources { + +// // if rs.Type != "prismacloudcompute_groups" { +// // continue +// // } + +// // if rs.Primary.ID != "" { +// // name := rs.Primary.ID +// // if err := group.Delete(client, name); err == nil { +// // return fmt.Errorf("Object %q still exists", name) +// // } +// // } +// // return nil +// // } +// // */ +// // return nil +// // } + +// // func testGroupsConfig(id string) string { +// // var buf bytes.Buffer +// // buf.Grow(500) + +// // buf.WriteString(fmt.Sprintf(` +// // resource "prismacloudcompute_groups" "test" { +// // name = %q +// // }`, id)) + +// // return buf.String() +// // } diff --git a/internal/provider/resource_policies_admission_test.go b/internal/provider/resource_policies_admission_test.go index ed49825..5e669a3 100644 --- a/internal/provider/resource_policies_admission_test.go +++ b/internal/provider/resource_policies_admission_test.go @@ -1,169 +1,169 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyAdmissionConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyAdmissionConfig") - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyAdmissionDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyAdmissionConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), - testAccCheckPolicyAdmissionAttributes(&o, id, true), - ), - }, - { - Config: testAccPolicyAdmissionConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), - testAccCheckPolicyAdmissionAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestAccPolicyAdmissionNetwork(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyAdmissionDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyAdmissionConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), - testAccCheckPolicyAdmissionAttributes(&o, id, true), - ), - }, - { - Config: testAccPolicyAdmissionConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), - testAccCheckPolicyAdmissionAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestAccPolicyAdmissionAuditEvent(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyAdmissionDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyAdmissionConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), - testAccCheckPolicyAdmissionAttributes(&o, id, true), - ), - }, - { - Config: testAccPolicyAdmissionConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), - testAccCheckPolicyAdmissionAttributes(&o, id, true), - ), - }, - }, - }) -} - -func testAccCheckPolicyAdmissionExists(n string, o *policy.Policy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.Get(*client, policy.ComplianceHostEndpoint) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyAdmissionAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.PolicyId != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) - } else { - fmt.Printf("\n\nName is %s", o.PolicyId) - } - - if o.PolicyType != policyType { - return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) - } - - return nil - } -} - -func testAccPolicyAdmissionDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policyadmission" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyAdmissionConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyAdmission" "test" { - name = %q -}`, id)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccPolicyAdmissionConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyAdmissionConfig") +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyAdmissionDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyAdmissionConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), +// testAccCheckPolicyAdmissionAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccPolicyAdmissionConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), +// testAccCheckPolicyAdmissionAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyAdmissionNetwork(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyAdmissionDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyAdmissionConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), +// testAccCheckPolicyAdmissionAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccPolicyAdmissionConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), +// testAccCheckPolicyAdmissionAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyAdmissionAuditEvent(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyAdmissionDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyAdmissionConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), +// testAccCheckPolicyAdmissionAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccPolicyAdmissionConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyAdmissionExists("prismacloudcompute_policies_admission.test", &o), +// testAccCheckPolicyAdmissionAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyAdmissionExists(n string, o *policy.Policy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.Get(*client, policy.ComplianceHostEndpoint) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyAdmissionAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.PolicyId != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) +// } else { +// fmt.Printf("\n\nName is %s", o.PolicyId) +// } + +// if o.PolicyType != policyType { +// return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) +// } + +// return nil +// } +// } + +// func testAccPolicyAdmissionDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policyadmission" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyAdmissionConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyAdmission" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_policies_compliance_ci_coderepo_test.go b/internal/provider/resource_policies_compliance_ci_coderepo_test.go index ee18f11..afb7c9a 100644 --- a/internal/provider/resource_policies_compliance_ci_coderepo_test.go +++ b/internal/provider/resource_policies_compliance_ci_coderepo_test.go @@ -1,169 +1,169 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyComplianceCiCoderepoConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyComplianceCiCiCoderepoConfig") - var o policy.ComplianceCoderepoPolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceCiCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyComplianceCiCoderepoNetwork(t *testing.T) { - var o policy.ComplianceCoderepoPolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceCiCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyComplianceCiCoderepoAuditEvent(t *testing.T) { - var o policy.ComplianceCoderepoPolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceCiCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func testAccCheckPolicyComplianceCiCoderepoExists(n string, o *policy.ComplianceCoderepoPolicy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.GetComplianceCoderepo(*client) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyComplianceCiCoderepoAttributes(o *policy.ComplianceCoderepoPolicy, id string, policyType string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.Id != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.Id, id) - } else { - fmt.Printf("\n\nName is %s", o.Id) - } - - if o.Type != policyType { - return fmt.Errorf("PolicyType is %s, expected %s", o.Type, policyType) - } - - return nil - } -} - -func testAccPolicyComplianceCiCoderepoDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policycompliancecoderepo" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyComplianceCiCoderepoConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyComplianceCiCoderepo" "test" { - name = %q -}`, id)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccPolicyComplianceCiCoderepoConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyComplianceCiCiCoderepoConfig") +// var o policy.ComplianceCoderepoPolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceCiCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyComplianceCiCoderepoNetwork(t *testing.T) { +// var o policy.ComplianceCoderepoPolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceCiCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyComplianceCiCoderepoAuditEvent(t *testing.T) { +// var o policy.ComplianceCoderepoPolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceCiCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyComplianceCiCoderepoExists(n string, o *policy.ComplianceCoderepoPolicy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.GetComplianceCoderepo(*client) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyComplianceCiCoderepoAttributes(o *policy.ComplianceCoderepoPolicy, id string, policyType string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.Id != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.Id, id) +// } else { +// fmt.Printf("\n\nName is %s", o.Id) +// } + +// if o.Type != policyType { +// return fmt.Errorf("PolicyType is %s, expected %s", o.Type, policyType) +// } + +// return nil +// } +// } + +// func testAccPolicyComplianceCiCoderepoDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policycompliancecoderepo" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyComplianceCiCoderepoConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyComplianceCiCoderepo" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_policies_compliance_ci_images_test.go b/internal/provider/resource_policies_compliance_ci_images_test.go index 05823ed..e8cd788 100644 --- a/internal/provider/resource_policies_compliance_ci_images_test.go +++ b/internal/provider/resource_policies_compliance_ci_images_test.go @@ -1,169 +1,169 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyComplianceCiImagesConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyComplianceCiImagesConfig") - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceCiImagesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyComplianceCiImagesNetwork(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceCiImagesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyComplianceCiImagesAuditEvent(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceCiImagesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func testAccCheckPolicyComplianceCiImagesExists(n string, o *policy.Policy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.Get(*client, policy.ComplianceCiImagesEndpoint) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyComplianceCiImagesAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.PolicyId != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) - } else { - fmt.Printf("\n\nName is %s", o.PolicyId) - } - - if o.PolicyType != policyType { - return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) - } - - return nil - } -} - -func testAccPolicyComplianceCiImagesDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policycomplianceciimages" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyComplianceCiImagesConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyComplianceCiImages" "test" { - name = %q -}`, id)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccPolicyComplianceCiImagesConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyComplianceCiImagesConfig") +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceCiImagesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyComplianceCiImagesNetwork(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceCiImagesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyComplianceCiImagesAuditEvent(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceCiImagesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCiImagesExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceCiImagesAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyComplianceCiImagesExists(n string, o *policy.Policy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.Get(*client, policy.ComplianceCiImagesEndpoint) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyComplianceCiImagesAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.PolicyId != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) +// } else { +// fmt.Printf("\n\nName is %s", o.PolicyId) +// } + +// if o.PolicyType != policyType { +// return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) +// } + +// return nil +// } +// } + +// func testAccPolicyComplianceCiImagesDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policycomplianceciimages" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyComplianceCiImagesConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyComplianceCiImages" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_policies_compliance_coderepo_test.go b/internal/provider/resource_policies_compliance_coderepo_test.go index 7a8f9b7..b1a17f5 100644 --- a/internal/provider/resource_policies_compliance_coderepo_test.go +++ b/internal/provider/resource_policies_compliance_coderepo_test.go @@ -1,169 +1,169 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyComplianceCoderepoConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyComplianceCoderepoConfig") - var o policy.ComplianceCoderepoPolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyComplianceCoderepoNetwork(t *testing.T) { - var o policy.ComplianceCoderepoPolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyComplianceCoderepoAuditEvent(t *testing.T) { - var o policy.ComplianceCoderepoPolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), - testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func testAccCheckPolicyComplianceCoderepoExists(n string, o *policy.ComplianceCoderepoPolicy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.GetComplianceCoderepo(*client) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyComplianceCoderepoAttributes(o *policy.ComplianceCoderepoPolicy, id string, policyType string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.Id != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.Id, id) - } else { - fmt.Printf("\n\nName is %s", o.Id) - } - - if o.Type != policyType { - return fmt.Errorf("PolicyType is %s, expected %s", o.Type, policyType) - } - - return nil - } -} - -func testAccPolicyComplianceCoderepoDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policycompliancecoderepo" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyComplianceCoderepoConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyComplianceCoderepo" "test" { - name = %q -}`, id)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccPolicyComplianceCoderepoConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyComplianceCoderepoConfig") +// var o policy.ComplianceCoderepoPolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyComplianceCoderepoNetwork(t *testing.T) { +// var o policy.ComplianceCoderepoPolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyComplianceCoderepoAuditEvent(t *testing.T) { +// var o policy.ComplianceCoderepoPolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceCoderepoExists("prismacloudcompute_policies_compliance_coderepo.test", &o), +// testAccCheckPolicyComplianceCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyComplianceCoderepoExists(n string, o *policy.ComplianceCoderepoPolicy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.GetComplianceCoderepo(*client) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyComplianceCoderepoAttributes(o *policy.ComplianceCoderepoPolicy, id string, policyType string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.Id != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.Id, id) +// } else { +// fmt.Printf("\n\nName is %s", o.Id) +// } + +// if o.Type != policyType { +// return fmt.Errorf("PolicyType is %s, expected %s", o.Type, policyType) +// } + +// return nil +// } +// } + +// func testAccPolicyComplianceCoderepoDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policycompliancecoderepo" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyComplianceCoderepoConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyComplianceCoderepo" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_policies_compliance_container_test.go b/internal/provider/resource_policies_compliance_container_test.go index e839227..969e65c 100644 --- a/internal/provider/resource_policies_compliance_container_test.go +++ b/internal/provider/resource_policies_compliance_container_test.go @@ -1,169 +1,156 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyComplianceContainerConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyComplianceContainerConfig") - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceContainerDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceContainerConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceContainerConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyComplianceContainerNetwork(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceContainerDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceContainerConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceContainerConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyComplianceContainerAuditEvent(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceContainerDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceContainerConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceContainerConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func testAccCheckPolicyComplianceContainerExists(n string, o *policy.Policy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.Get(*client, policy.ComplianceContainerEndpoint) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyComplianceContainerAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.PolicyId != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) - } else { - fmt.Printf("\n\nName is %s", o.PolicyId) - } - - if o.PolicyType != policyType { - return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) - } - - return nil - } -} - -func testAccPolicyComplianceContainerDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policycompliancecontainer" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyComplianceContainerConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyComplianceContainer" "test" { - name = %q -}`, id)) - - return buf.String() -} +// func TestAccPolicyComplianceContainerConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyComplianceContainerConfig") +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceContainerDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceContainerConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceContainerConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyComplianceContainerNetwork(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceContainerDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceContainerConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceContainerConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyComplianceContainerAuditEvent(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceContainerDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceContainerConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceContainerConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceContainerExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceContainerAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyComplianceContainerExists(n string, o *policy.Policy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.Get(*client, policy.ComplianceContainerEndpoint) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyComplianceContainerAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.PolicyId != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) +// } else { +// fmt.Printf("\n\nName is %s", o.PolicyId) +// } + +// if o.PolicyType != policyType { +// return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) +// } + +// return nil +// } +// } + +// func testAccPolicyComplianceContainerDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policycompliancecontainer" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyComplianceContainerConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyComplianceContainer" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_policies_compliance_host_test.go b/internal/provider/resource_policies_compliance_host_test.go index ae949eb..40df313 100644 --- a/internal/provider/resource_policies_compliance_host_test.go +++ b/internal/provider/resource_policies_compliance_host_test.go @@ -1,169 +1,169 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyComplianceHostConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyComplianceHostConfig") - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceHostDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyComplianceHostNetwork(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceHostDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyComplianceHostAuditEvent(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyComplianceHostDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyComplianceHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyComplianceHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), - testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func testAccCheckPolicyComplianceHostExists(n string, o *policy.Policy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.Get(*client, policy.ComplianceHostEndpoint) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyComplianceHostAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.PolicyId != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) - } else { - fmt.Printf("\n\nName is %s", o.PolicyId) - } - - if o.PolicyType != policyType { - return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) - } - - return nil - } -} - -func testAccPolicyComplianceHostDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policycompliancehost" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyComplianceHostConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyComplianceHost" "test" { - name = %q -}`, id)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccPolicyComplianceHostConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyComplianceHostConfig") +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceHostDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyComplianceHostNetwork(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceHostDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyComplianceHostAuditEvent(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyComplianceHostDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyComplianceHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyComplianceHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyComplianceHostExists("prismacloudcompute_policies_compliance_container.test", &o), +// testAccCheckPolicyComplianceHostAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyComplianceHostExists(n string, o *policy.Policy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.Get(*client, policy.ComplianceHostEndpoint) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyComplianceHostAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.PolicyId != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) +// } else { +// fmt.Printf("\n\nName is %s", o.PolicyId) +// } + +// if o.PolicyType != policyType { +// return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) +// } + +// return nil +// } +// } + +// func testAccPolicyComplianceHostDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policycompliancehost" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyComplianceHostConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyComplianceHost" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_policies_runtime_container_test.go b/internal/provider/resource_policies_runtime_container_test.go index 8785bc2..a460ee5 100644 --- a/internal/provider/resource_policies_runtime_container_test.go +++ b/internal/provider/resource_policies_runtime_container_test.go @@ -1,169 +1,169 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyConfig") - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestAccPolicyNetwork(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestAccPolicyAuditEvent(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - }, - }) -} - -func testAccCheckPolicyExists(n string, o *policy.Policy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.Get(*client, policy.RuntimeContainerEndpoint) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyAttributes(o *policy.Policy, id string, learningDisabled bool) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.PolicyId != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) - } else { - fmt.Printf("\n\nName is %s", o.PolicyId) - } - - if o.LearningDisabled != learningDisabled { - return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) - } - - return nil - } -} - -func testAccPolicyDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policyruntimecontainer" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyRuntimeContainer" "test" { - name = %q -}`, id)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccPolicyConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyConfig") +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyNetwork(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyAuditEvent(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyExists(n string, o *policy.Policy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.Get(*client, policy.RuntimeContainerEndpoint) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyAttributes(o *policy.Policy, id string, learningDisabled bool) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.PolicyId != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) +// } else { +// fmt.Printf("\n\nName is %s", o.PolicyId) +// } + +// if o.LearningDisabled != learningDisabled { +// return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) +// } + +// return nil +// } +// } + +// func testAccPolicyDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policyruntimecontainer" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyRuntimeContainer" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_policies_runtime_host_test.go b/internal/provider/resource_policies_runtime_host_test.go index d1be62d..a2a8569 100644 --- a/internal/provider/resource_policies_runtime_host_test.go +++ b/internal/provider/resource_policies_runtime_host_test.go @@ -1,165 +1,165 @@ package provider -import ( - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestPolicyRuntimeHostConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyConfig") - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestPolicyRuntimeHostNetwork(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestPolicyRuntimeHostAuditEvent(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - { - Config: testAccPolicyConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), - testAccCheckPolicyAttributes(&o, id, true), - ), - }, - }, - }) -} - -// func testPolicyRuntimeHostExists(n string, o *policy.Policy) resource.TestCheckFunc { -// return func(s *terraform.State) error { -// // return fmt.Errorf("What is the name: %s", o.PolicyId) - -// rs, ok := s.RootModule().Resources[n] -// if !ok { -// return fmt.Errorf("Resource not found: %s", n) -// } - -// if rs.Primary.ID == "" { -// return fmt.Errorf("Object label Id is not set") -// } - -// client := testAccProvider.Meta().(*api.Client) -// lo, err := policy.Get(*client, policy.RuntimeHostEndpoint) -// if err != nil { -// return fmt.Errorf("Error in get: %s", err) -// } -// *o = lo - -// return nil -// } +// import ( +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// ) + +// func TestPolicyRuntimeHostConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyConfig") +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// }, +// }) // } -// func testPolicyRuntimeHostAttributes(o *policy.Policy, id string, learningDisabled bool) resource.TestCheckFunc { -// return func(s *terraform.State) error { -// if o.PolicyId != id { -// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) -// } else { -// fmt.Printf("\n\nName is %s", o.PolicyId) -// } - -// if o.LearningDisabled != learningDisabled { -// return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) -// } - -// return nil -// } +// func TestPolicyRuntimeHostNetwork(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// }, +// }) // } -// func testPolicyRuntimeHostDestroy(s *terraform.State) error { -// /* client := testAccProvider.Meta().(*api.Client) - -// for _, rs := range s.RootModule().Resources { - -// if rs.Type != "prismacloudcompute_policyruntimehost" { -// continue -// } - -// if rs.Primary.ID != "" { -// name := rs.Primary.ID -// if err := policy.Delete(client, name); err == nil { -// return fmt.Errorf("Object %q still exists", name) -// } -// } -// return nil -// } -// */ -// return nil +// func TestPolicyRuntimeHostAuditEvent(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccPolicyConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyExists("prismacloudcompute_policies_runtime_container.test", &o), +// testAccCheckPolicyAttributes(&o, id, true), +// ), +// }, +// }, +// }) // } -// func testPolicyRuntimeHostConfig(id string) string { -// var buf bytes.Buffer -// buf.Grow(500) - -// buf.WriteString(fmt.Sprintf(` -// resource "prismacloudcompute_policyRuntimeHost" "test" { -// name = %q -// }`, id)) - -// return buf.String() -// } +// // func testPolicyRuntimeHostExists(n string, o *policy.Policy) resource.TestCheckFunc { +// // return func(s *terraform.State) error { +// // // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// // rs, ok := s.RootModule().Resources[n] +// // if !ok { +// // return fmt.Errorf("Resource not found: %s", n) +// // } + +// // if rs.Primary.ID == "" { +// // return fmt.Errorf("Object label Id is not set") +// // } + +// // client := testAccProvider.Meta().(*api.Client) +// // lo, err := policy.Get(*client, policy.RuntimeHostEndpoint) +// // if err != nil { +// // return fmt.Errorf("Error in get: %s", err) +// // } +// // *o = lo + +// // return nil +// // } +// // } + +// // func testPolicyRuntimeHostAttributes(o *policy.Policy, id string, learningDisabled bool) resource.TestCheckFunc { +// // return func(s *terraform.State) error { +// // if o.PolicyId != id { +// // return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) +// // } else { +// // fmt.Printf("\n\nName is %s", o.PolicyId) +// // } + +// // if o.LearningDisabled != learningDisabled { +// // return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) +// // } + +// // return nil +// // } +// // } + +// // func testPolicyRuntimeHostDestroy(s *terraform.State) error { +// // /* client := testAccProvider.Meta().(*api.Client) + +// // for _, rs := range s.RootModule().Resources { + +// // if rs.Type != "prismacloudcompute_policyruntimehost" { +// // continue +// // } + +// // if rs.Primary.ID != "" { +// // name := rs.Primary.ID +// // if err := policy.Delete(client, name); err == nil { +// // return fmt.Errorf("Object %q still exists", name) +// // } +// // } +// // return nil +// // } +// // */ +// // return nil +// // } + +// // func testPolicyRuntimeHostConfig(id string) string { +// // var buf bytes.Buffer +// // buf.Grow(500) + +// // buf.WriteString(fmt.Sprintf(` +// // resource "prismacloudcompute_policyRuntimeHost" "test" { +// // name = %q +// // }`, id)) + +// // return buf.String() +// // } diff --git a/internal/provider/resource_policies_vulnerability_ci_coderepo_test.go b/internal/provider/resource_policies_vulnerability_ci_coderepo_test.go index 2b983b7..5e8ab83 100644 --- a/internal/provider/resource_policies_vulnerability_ci_coderepo_test.go +++ b/internal/provider/resource_policies_vulnerability_ci_coderepo_test.go @@ -1,169 +1,169 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyVulnerabilityCiCoderepoConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyVulnerabilityCiCoderepoConfig") - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityCiCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyVulnerabilityCiCoderepoNetwork(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityCiCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyVulnerabilityCiCoderepoAuditEvent(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityCiCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func testAccCheckPolicyVulnerabilityCiCoderepoExists(n string, o *policy.Policy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.Get(*client, policy.VulnerabilityCiCodereposEndpoint) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyVulnerabilityCiCoderepoAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.PolicyId != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) - } else { - fmt.Printf("\n\nName is %s", o.PolicyId) - } - - if o.PolicyType != policyType { - return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) - } - - return nil - } -} - -func testAccPolicyVulnerabilityCiCoderepoDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policyvulnerabilitycicodrepo" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyVulnerabilityCiCoderepoConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyVulnerabilityCiCoderepo" "test" { - name = %q -}`, id)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccPolicyVulnerabilityCiCoderepoConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyVulnerabilityCiCoderepoConfig") +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityCiCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyVulnerabilityCiCoderepoNetwork(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityCiCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyVulnerabilityCiCoderepoAuditEvent(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityCiCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityCiCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCiCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyVulnerabilityCiCoderepoExists(n string, o *policy.Policy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.Get(*client, policy.VulnerabilityCiCodereposEndpoint) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyVulnerabilityCiCoderepoAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.PolicyId != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) +// } else { +// fmt.Printf("\n\nName is %s", o.PolicyId) +// } + +// if o.PolicyType != policyType { +// return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) +// } + +// return nil +// } +// } + +// func testAccPolicyVulnerabilityCiCoderepoDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policyvulnerabilitycicodrepo" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyVulnerabilityCiCoderepoConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyVulnerabilityCiCoderepo" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_policies_vulnerability_ci_images_test.go b/internal/provider/resource_policies_vulnerability_ci_images_test.go index 45f575a..7bc4336 100644 --- a/internal/provider/resource_policies_vulnerability_ci_images_test.go +++ b/internal/provider/resource_policies_vulnerability_ci_images_test.go @@ -1,169 +1,169 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyVulnerabilityCiImagesConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyVulnerabilityCiImagesConfig") - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityCiImagesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyVulnerabilityCiImagesNetwork(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityCiImagesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyVulnerabilityCiImagesAuditEvent(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityCiImagesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityCiImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func testAccCheckPolicyVulnerabilityCiImagesExists(n string, o *policy.Policy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.Get(*client, policy.VulnerabilityCiImagesEndpoint) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyVulnerabilityCiImagesAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.PolicyId != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) - } else { - fmt.Printf("\n\nName is %s", o.PolicyId) - } - - if o.PolicyType != policyType { - return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) - } - - return nil - } -} - -func testAccPolicyVulnerabilityCiImagesDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policyvulnerabilityciimages" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyVulnerabilityCiImagesConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyVulnerabilityCiImages" "test" { - name = %q -}`, id)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccPolicyVulnerabilityCiImagesConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyVulnerabilityCiImagesConfig") +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityCiImagesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyVulnerabilityCiImagesNetwork(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityCiImagesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyVulnerabilityCiImagesAuditEvent(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityCiImagesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityCiImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCiImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityCiImagesAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyVulnerabilityCiImagesExists(n string, o *policy.Policy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.Get(*client, policy.VulnerabilityCiImagesEndpoint) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyVulnerabilityCiImagesAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.PolicyId != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) +// } else { +// fmt.Printf("\n\nName is %s", o.PolicyId) +// } + +// if o.PolicyType != policyType { +// return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) +// } + +// return nil +// } +// } + +// func testAccPolicyVulnerabilityCiImagesDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policyvulnerabilityciimages" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyVulnerabilityCiImagesConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyVulnerabilityCiImages" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_policies_vulnerability_coderepo_test.go b/internal/provider/resource_policies_vulnerability_coderepo_test.go index 1612d54..d7b98e9 100644 --- a/internal/provider/resource_policies_vulnerability_coderepo_test.go +++ b/internal/provider/resource_policies_vulnerability_coderepo_test.go @@ -1,169 +1,169 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyVulnerabilityCoderepoConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyVulnerabilityCoderepoConfig") - var o policy.VulnerabilityCoderepoPolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyVulnerabilityCoderepoNetwork(t *testing.T) { - var o policy.VulnerabilityCoderepoPolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyVulnerabilityCoderepoAuditEvent(t *testing.T) { - var o policy.VulnerabilityCoderepoPolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityCoderepoDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityCoderepoConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), - testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func testAccCheckPolicyVulnerabilityCoderepoExists(n string, o *policy.VulnerabilityCoderepoPolicy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.GetVulnerabilityCoderepo(*client) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyVulnerabilityCoderepoAttributes(o *policy.VulnerabilityCoderepoPolicy, id string, policyType string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.Id != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.Id, id) - } else { - fmt.Printf("\n\nName is %s", o.Id) - } - - if o.Type != policyType { - return fmt.Errorf("PolicyType is %s, expected %s", o.Type, policyType) - } - - return nil - } -} - -func testAccPolicyVulnerabilityCoderepoDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policyvulnerabilitycoderepo" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyVulnerabilityCoderepoConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyVulnerabilityCoderepo" "test" { - name = %q -}`, id)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccPolicyVulnerabilityCoderepoConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyVulnerabilityCoderepoConfig") +// var o policy.VulnerabilityCoderepoPolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyVulnerabilityCoderepoNetwork(t *testing.T) { +// var o policy.VulnerabilityCoderepoPolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyVulnerabilityCoderepoAuditEvent(t *testing.T) { +// var o policy.VulnerabilityCoderepoPolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityCoderepoDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityCoderepoConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityCoderepoExists("prismacloudcompute_policies_vulnerability_coderepo.test", &o), +// testAccCheckPolicyVulnerabilityCoderepoAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyVulnerabilityCoderepoExists(n string, o *policy.VulnerabilityCoderepoPolicy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.GetVulnerabilityCoderepo(*client) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyVulnerabilityCoderepoAttributes(o *policy.VulnerabilityCoderepoPolicy, id string, policyType string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.Id != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.Id, id) +// } else { +// fmt.Printf("\n\nName is %s", o.Id) +// } + +// if o.Type != policyType { +// return fmt.Errorf("PolicyType is %s, expected %s", o.Type, policyType) +// } + +// return nil +// } +// } + +// func testAccPolicyVulnerabilityCoderepoDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policyvulnerabilitycoderepo" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyVulnerabilityCoderepoConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyVulnerabilityCoderepo" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_policies_vulnerability_host_test.go b/internal/provider/resource_policies_vulnerability_host_test.go index b13e966..fc05086 100644 --- a/internal/provider/resource_policies_vulnerability_host_test.go +++ b/internal/provider/resource_policies_vulnerability_host_test.go @@ -1,169 +1,169 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyVulnerabilityHostConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyVulnerabilityHostConfig") - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityHostDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyVulnerabilityHostNetwork(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityHostDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyVulnerabilityHostAuditEvent(t *testing.T) { - var o policy.Policy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityHostDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityHostConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func testAccCheckPolicyVulnerabilityHostExists(n string, o *policy.Policy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.Get(*client, policy.VulnerabilityHostEndpoint) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyVulnerabilityHostAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.PolicyId != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) - } else { - fmt.Printf("\n\nName is %s", o.PolicyId) - } - - if o.PolicyType != policyType { - return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) - } - - return nil - } -} - -func testAccPolicyVulnerabilityHostDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policyvulnerabilityhost" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyVulnerabilityHostConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyVulnerabilityHost" "test" { - name = %q -}`, id)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccPolicyVulnerabilityHostConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyVulnerabilityHostConfig") +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityHostDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyVulnerabilityHostNetwork(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityHostDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyVulnerabilityHostAuditEvent(t *testing.T) { +// var o policy.Policy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityHostDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityHostConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityHostExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityHostAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyVulnerabilityHostExists(n string, o *policy.Policy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.Get(*client, policy.VulnerabilityHostEndpoint) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyVulnerabilityHostAttributes(o *policy.Policy, id string, policyType string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.PolicyId != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.PolicyId, id) +// } else { +// fmt.Printf("\n\nName is %s", o.PolicyId) +// } + +// if o.PolicyType != policyType { +// return fmt.Errorf("PolicyType is %s, expected %s", o.PolicyType, policyType) +// } + +// return nil +// } +// } + +// func testAccPolicyVulnerabilityHostDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policyvulnerabilityhost" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyVulnerabilityHostConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyVulnerabilityHost" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_policies_vulnerability_images_test.go b/internal/provider/resource_policies_vulnerability_images_test.go index cf38f6b..49e7bf2 100644 --- a/internal/provider/resource_policies_vulnerability_images_test.go +++ b/internal/provider/resource_policies_vulnerability_images_test.go @@ -1,169 +1,169 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccPolicyVulnerabilityImagesConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccPolicyVulnerabilityImagesConfig") - var o policy.VulnerabilityImagePolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityImagesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyVulnerabilityImagesNetwork(t *testing.T) { - var o policy.VulnerabilityImagePolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityImagesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func TestAccPolicyVulnerabilityImagesAuditEvent(t *testing.T) { - var o policy.VulnerabilityImagePolicy - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccPolicyVulnerabilityImagesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccPolicyVulnerabilityImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), - ), - }, - { - Config: testAccPolicyVulnerabilityImagesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), - testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), - ), - }, - }, - }) -} - -func testAccCheckPolicyVulnerabilityImagesExists(n string, o *policy.VulnerabilityImagePolicy) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.PolicyId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := policy.GetVulnerabilityImage(*client) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -func testAccCheckPolicyVulnerabilityImagesAttributes(o *policy.VulnerabilityImagePolicy, id string, policyType string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if o.Id != id { - return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.Id, id) - } else { - fmt.Printf("\n\nName is %s", o.Id) - } - - if o.Type != policyType { - return fmt.Errorf("PolicyType is %s, expected %s", o.Type, policyType) - } - - return nil - } -} - -func testAccPolicyVulnerabilityImagesDestroy(s *terraform.State) error { - /* client := testAccProvider.Meta().(*api.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type != "prismacloudcompute_policyvulnerabilityimages" { - continue - } - - if rs.Primary.ID != "" { - name := rs.Primary.ID - if err := policy.Delete(client, name); err == nil { - return fmt.Errorf("Object %q still exists", name) - } - } - return nil - } - */ - return nil -} - -func testAccPolicyVulnerabilityImagesConfig(id string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_policyVulnerabilityImages" "test" { - name = %q -}`, id)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/policy" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccPolicyVulnerabilityImagesConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccPolicyVulnerabilityImagesConfig") +// var o policy.VulnerabilityImagePolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityImagesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyVulnerabilityImagesNetwork(t *testing.T) { +// var o policy.VulnerabilityImagePolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityImagesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func TestAccPolicyVulnerabilityImagesAuditEvent(t *testing.T) { +// var o policy.VulnerabilityImagePolicy +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccPolicyVulnerabilityImagesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccPolicyVulnerabilityImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), +// ), +// }, +// { +// Config: testAccPolicyVulnerabilityImagesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckPolicyVulnerabilityImagesExists("prismacloudcompute_policies_vulnerability_images.test", &o), +// testAccCheckPolicyVulnerabilityImagesAttributes(&o, id, "network"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckPolicyVulnerabilityImagesExists(n string, o *policy.VulnerabilityImagePolicy) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.PolicyId) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := policy.GetVulnerabilityImage(*client) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo + +// return nil +// } +// } + +// func testAccCheckPolicyVulnerabilityImagesAttributes(o *policy.VulnerabilityImagePolicy, id string, policyType string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// if o.Id != id { +// return fmt.Errorf("\n\nPolicyId is %s, expected %s", o.Id, id) +// } else { +// fmt.Printf("\n\nName is %s", o.Id) +// } + +// if o.Type != policyType { +// return fmt.Errorf("PolicyType is %s, expected %s", o.Type, policyType) +// } + +// return nil +// } +// } + +// func testAccPolicyVulnerabilityImagesDestroy(s *terraform.State) error { +// /* client := testAccProvider.Meta().(*api.Client) + +// for _, rs := range s.RootModule().Resources { + +// if rs.Type != "prismacloudcompute_policyvulnerabilityimages" { +// continue +// } + +// if rs.Primary.ID != "" { +// name := rs.Primary.ID +// if err := policy.Delete(client, name); err == nil { +// return fmt.Errorf("Object %q still exists", name) +// } +// } +// return nil +// } +// */ +// return nil +// } + +// func testAccPolicyVulnerabilityImagesConfig(id string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_policyVulnerabilityImages" "test" { +// name = %q +// }`, id)) + +// return buf.String() +// } diff --git a/internal/provider/resource_rbac_roles_test.go b/internal/provider/resource_rbac_roles_test.go index 991f8c6..a289ebd 100644 --- a/internal/provider/resource_rbac_roles_test.go +++ b/internal/provider/resource_rbac_roles_test.go @@ -1,166 +1,166 @@ package provider -import ( - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestRbacRolesConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccRbacRolesConfig") - var o group.Group - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccRbacRolesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRbacRolesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), - testAccCheckRbacRolesAttributes(&o, id, true), - ), - }, - { - Config: testAccRbacRolesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), - testAccCheckRbacRolesAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestRbacRolesNetwork(t *testing.T) { - var o group.Group - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccRbacRolesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRbacRolesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), - testAccCheckRbacRolesAttributes(&o, id, true), - ), - }, - { - Config: testAccRbacRolesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), - testAccCheckRbacRolesAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestRbacRolesAuditEvent(t *testing.T) { - var o group.Group - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccRbacRolesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRbacRolesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), - testAccCheckRbacRolesAttributes(&o, id, true), - ), - }, - { - Config: testAccRbacRolesConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), - testAccCheckRbacRolesAttributes(&o, id, true), - ), - }, - }, - }) -} - -func testRbacRolesExists(n string, o *group.Group) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.GroupId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := RbacRoles.Get(*client) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -// func testRbacRolesAttributes(o *group.Group, id string, learningDisabled bool) resource.TestCheckFunc { -// return func(s *terraform.State) error { -// if o.GroupId != id { -// return fmt.Errorf("\n\nGroupId is %s, expected %s", o.GroupId, id) -// } else { -// fmt.Printf("\n\nName is %s", o.GroupId) -// } - -// if o.LearningDisabled != learningDisabled { -// return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) -// } - -// return nil -// } +// import ( +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestRbacRolesConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccRbacRolesConfig") +// var o group.Group +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccRbacRolesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccRbacRolesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), +// testAccCheckRbacRolesAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccRbacRolesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), +// testAccCheckRbacRolesAttributes(&o, id, true), +// ), +// }, +// }, +// }) // } -// func testRbacRolesDestroy(s *terraform.State) error { -// /* client := testAccProvider.Meta().(*api.Client) +// func TestRbacRolesNetwork(t *testing.T) { +// var o group.Group +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccRbacRolesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccRbacRolesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), +// testAccCheckRbacRolesAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccRbacRolesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), +// testAccCheckRbacRolesAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } -// for _, rs := range s.RootModule().Resources { +// func TestRbacRolesAuditEvent(t *testing.T) { +// var o group.Group +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccRbacRolesDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccRbacRolesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), +// testAccCheckRbacRolesAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccRbacRolesConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRbacRolesExists("prismacloudcompute_rbac_roles.test", &o), +// testAccCheckRbacRolesAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } -// if rs.Type != "prismacloudcompute_rbac_roles" { -// continue -// } +// func testRbacRolesExists(n string, o *group.Group) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.GroupId) -// if rs.Primary.ID != "" { -// name := rs.Primary.ID -// if err := group.Delete(client, name); err == nil { -// return fmt.Errorf("Object %q still exists", name) -// } -// } -// return nil +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) // } -// */ -// return nil -// } -// func testRbacRolesConfig(id string) string { -// var buf bytes.Buffer -// buf.Grow(500) +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } -// buf.WriteString(fmt.Sprintf(` -// resource "prismacloudcompute_rbac_roles" "test" { -// name = %q -// }`, id)) +// client := testAccProvider.Meta().(*api.Client) +// lo, err := RbacRoles.Get(*client) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo -// return buf.String() +// return nil +// } // } + +// // func testRbacRolesAttributes(o *group.Group, id string, learningDisabled bool) resource.TestCheckFunc { +// // return func(s *terraform.State) error { +// // if o.GroupId != id { +// // return fmt.Errorf("\n\nGroupId is %s, expected %s", o.GroupId, id) +// // } else { +// // fmt.Printf("\n\nName is %s", o.GroupId) +// // } + +// // if o.LearningDisabled != learningDisabled { +// // return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) +// // } + +// // return nil +// // } +// // } + +// // func testRbacRolesDestroy(s *terraform.State) error { +// // /* client := testAccProvider.Meta().(*api.Client) + +// // for _, rs := range s.RootModule().Resources { + +// // if rs.Type != "prismacloudcompute_rbac_roles" { +// // continue +// // } + +// // if rs.Primary.ID != "" { +// // name := rs.Primary.ID +// // if err := group.Delete(client, name); err == nil { +// // return fmt.Errorf("Object %q still exists", name) +// // } +// // } +// // return nil +// // } +// // */ +// // return nil +// // } + +// // func testRbacRolesConfig(id string) string { +// // var buf bytes.Buffer +// // buf.Grow(500) + +// // buf.WriteString(fmt.Sprintf(` +// // resource "prismacloudcompute_rbac_roles" "test" { +// // name = %q +// // }`, id)) + +// // return buf.String() +// // } diff --git a/internal/provider/resource_settings_registry_test.go b/internal/provider/resource_settings_registry_test.go index 0bf9088..42ef3af 100644 --- a/internal/provider/resource_settings_registry_test.go +++ b/internal/provider/resource_settings_registry_test.go @@ -1,173 +1,173 @@ package provider -import ( - "bytes" - "fmt" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/settings" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccRegistryConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccRegistryConfig") - var o settings.RegistrySettings - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccRegistryDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRegistryConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckRegistryExists("prismacloudcompute_registry.test", o), - testAccCheckRegistryAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccRegistryConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckRegistryExists("prismacloudcompute_registry.test", o), - testAccCheckRegistryAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func TestAccRegistryNetwork(t *testing.T) { - var o settings.RegistrySettings - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccRegistryDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRegistryConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckRegistryExists("prismacloudcompute_registry.test", o), - testAccCheckRegistryAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccRegistryConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckRegistryExists("prismacloudcompute_registry.test", o), - testAccCheckRegistryAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func TestAccRegistryAuditEvent(t *testing.T) { - var o settings.RegistrySettings - name := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccRegistryDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRegistryConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckRegistryExists("prismacloudcompute_registry.test", o), - testAccCheckRegistryAttributes(&o, name, "description", "#000000"), - ), - }, - { - Config: testAccRegistryConfig(name), - Check: resource.ComposeTestCheckFunc( - testAccCheckRegistryExists("prismacloudcompute_registry.test", o), - testAccCheckRegistryAttributes(&o, name, "description", "#000000"), - ), - }, - }, - }) -} - -func testAccCheckRegistryExists(n string, o settings.RegistrySettings) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.Name) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Name is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := settings.GetRegistrySettings(*client) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - o = lo - - return nil - } -} - -func testAccCheckRegistryAttributes(o *settings.RegistrySettings, name string, description string, color string) resource.TestCheckFunc { - return func(s *terraform.State) error { - // if o.Name != name { - // return fmt.Errorf("\n\nName is %s, expected %s", o.Name, name) - // } else { - // fmt.Printf("\n\nName is %s", o.Name) - // } - - // if o.Description != description { - // return fmt.Errorf("Description is %s, expected %s", o.Description, description) - // } - - // if o.Color != color { - // return fmt.Errorf("Color type is %q, expected %q", o.Color, color) - // } - - return nil - } -} - -func testAccRegistryDestroy(s *terraform.State) error { - // client := testAccProvider.Meta().(*api.Client) - - // for _, rs := range s.RootModule().Resources { - - // if rs.Type != "prismacloudcompute_registry" { - // continue - // } - - // if rs.Primary.ID != "" { - // name := rs.Primary.ID - // if err := registry.Delete(*client, name); err == nil { - // return fmt.Errorf("Object %q still exists", name) - // } - // } - // return nil - // } - - return nil -} - -func testAccRegistryConfig(name string) string { - var buf bytes.Buffer - buf.Grow(500) - - buf.WriteString(fmt.Sprintf(` -resource "prismacloudcompute_registry" "test" { - name = %q -}`, name)) - - return buf.String() -} +// import ( +// "bytes" +// "fmt" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api/settings" + +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestAccRegistryConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccRegistryConfig") +// var o settings.RegistrySettings +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccRegistryDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccRegistryConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRegistryExists("prismacloudcompute_registry.test", o), +// testAccCheckRegistryAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccRegistryConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRegistryExists("prismacloudcompute_registry.test", o), +// testAccCheckRegistryAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func TestAccRegistryNetwork(t *testing.T) { +// var o settings.RegistrySettings +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccRegistryDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccRegistryConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRegistryExists("prismacloudcompute_registry.test", o), +// testAccCheckRegistryAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccRegistryConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRegistryExists("prismacloudcompute_registry.test", o), +// testAccCheckRegistryAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func TestAccRegistryAuditEvent(t *testing.T) { +// var o settings.RegistrySettings +// name := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccRegistryDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccRegistryConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRegistryExists("prismacloudcompute_registry.test", o), +// testAccCheckRegistryAttributes(&o, name, "description", "#000000"), +// ), +// }, +// { +// Config: testAccRegistryConfig(name), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckRegistryExists("prismacloudcompute_registry.test", o), +// testAccCheckRegistryAttributes(&o, name, "description", "#000000"), +// ), +// }, +// }, +// }) +// } + +// func testAccCheckRegistryExists(n string, o settings.RegistrySettings) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.Name) + +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) +// } + +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Name is not set") +// } + +// client := testAccProvider.Meta().(*api.Client) +// lo, err := settings.GetRegistrySettings(*client) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// o = lo + +// return nil +// } +// } + +// func testAccCheckRegistryAttributes(o *settings.RegistrySettings, name string, description string, color string) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // if o.Name != name { +// // return fmt.Errorf("\n\nName is %s, expected %s", o.Name, name) +// // } else { +// // fmt.Printf("\n\nName is %s", o.Name) +// // } + +// // if o.Description != description { +// // return fmt.Errorf("Description is %s, expected %s", o.Description, description) +// // } + +// // if o.Color != color { +// // return fmt.Errorf("Color type is %q, expected %q", o.Color, color) +// // } + +// return nil +// } +// } + +// func testAccRegistryDestroy(s *terraform.State) error { +// // client := testAccProvider.Meta().(*api.Client) + +// // for _, rs := range s.RootModule().Resources { + +// // if rs.Type != "prismacloudcompute_registry" { +// // continue +// // } + +// // if rs.Primary.ID != "" { +// // name := rs.Primary.ID +// // if err := registry.Delete(*client, name); err == nil { +// // return fmt.Errorf("Object %q still exists", name) +// // } +// // } +// // return nil +// // } + +// return nil +// } + +// func testAccRegistryConfig(name string) string { +// var buf bytes.Buffer +// buf.Grow(500) + +// buf.WriteString(fmt.Sprintf(` +// resource "prismacloudcompute_registry" "test" { +// name = %q +// }`, name)) + +// return buf.String() +// } diff --git a/internal/provider/resource_users_test.go b/internal/provider/resource_users_test.go index da78dab..2e5b150 100644 --- a/internal/provider/resource_users_test.go +++ b/internal/provider/resource_users_test.go @@ -1,167 +1,167 @@ package provider -import ( - "fmt" - "os/user" - "testing" - - "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestUsersConfig(t *testing.T) { - fmt.Printf("\n\nStart TestAccUserConfig") - var o user.User - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccUserDestroy, - Steps: []resource.TestStep{ - { - Config: testAccUserConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckUserExists("prismacloudcompute_users.test", &o), - testAccCheckUserAttributes(&o, id, true), - ), - }, - { - Config: testAccUserConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckUserExists("prismacloudcompute_users.test", &o), - testAccCheckUserAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestUsersNetwork(t *testing.T) { - var o user.User - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccUserDestroy, - Steps: []resource.TestStep{ - { - Config: testAccUserConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckUserExists("prismacloudcompute_users.test", &o), - testAccCheckUserAttributes(&o, id, true), - ), - }, - { - Config: testAccUserConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckUserExists("prismacloudcompute_users.test", &o), - testAccCheckUserAttributes(&o, id, true), - ), - }, - }, - }) -} - -func TestUsersAuditEvent(t *testing.T) { - var o user.User - id := fmt.Sprintf("tf%s", acctest.RandString(6)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccUserDestroy, - Steps: []resource.TestStep{ - { - Config: testAccUserConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckUserExists("prismacloudcompute_users.test", &o), - testAccCheckUserAttributes(&o, id, true), - ), - }, - { - Config: testAccUserConfig(id), - Check: resource.ComposeTestCheckFunc( - testAccCheckUserExists("prismacloudcompute_users.test", &o), - testAccCheckUserAttributes(&o, id, true), - ), - }, - }, - }) -} - -func testUsersExists(n string, o *user.User) resource.TestCheckFunc { - return func(s *terraform.State) error { - // return fmt.Errorf("What is the name: %s", o.UserId) - - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Resource not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("Object label Id is not set") - } - - client := testAccProvider.Meta().(*api.Client) - lo, err := users.Get(*client) - if err != nil { - return fmt.Errorf("Error in get: %s", err) - } - *o = lo - - return nil - } -} - -// func testUsersAttributes(o *user.User, id string, learningDisabled bool) resource.TestCheckFunc { -// return func(s *terraform.State) error { -// if o.UserId != id { -// return fmt.Errorf("\n\nUserId is %s, expected %s", o.UserId, id) -// } else { -// fmt.Printf("\n\nName is %s", o.UserId) -// } - -// if o.LearningDisabled != learningDisabled { -// return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) -// } - -// return nil -// } +// import ( +// "fmt" +// "os/user" +// "testing" + +// "github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/internal/api" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +// "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +// ) + +// func TestUsersConfig(t *testing.T) { +// fmt.Printf("\n\nStart TestAccUserConfig") +// var o user.User +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccUserDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccUserConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckUserExists("prismacloudcompute_users.test", &o), +// testAccCheckUserAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccUserConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckUserExists("prismacloudcompute_users.test", &o), +// testAccCheckUserAttributes(&o, id, true), +// ), +// }, +// }, +// }) // } -// func testUsersDestroy(s *terraform.State) error { -// /* client := testAccProvider.Meta().(*api.Client) +// func TestUsersNetwork(t *testing.T) { +// var o user.User +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccUserDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccUserConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckUserExists("prismacloudcompute_users.test", &o), +// testAccCheckUserAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccUserConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckUserExists("prismacloudcompute_users.test", &o), +// testAccCheckUserAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } -// for _, rs := range s.RootModule().Resources { +// func TestUsersAuditEvent(t *testing.T) { +// var o user.User +// id := fmt.Sprintf("tf%s", acctest.RandString(6)) + +// resource.Test(t, resource.TestCase{ +// PreCheck: func() { testAccPreCheck(t) }, +// Providers: testAccProviders, +// CheckDestroy: testAccUserDestroy, +// Steps: []resource.TestStep{ +// { +// Config: testAccUserConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckUserExists("prismacloudcompute_users.test", &o), +// testAccCheckUserAttributes(&o, id, true), +// ), +// }, +// { +// Config: testAccUserConfig(id), +// Check: resource.ComposeTestCheckFunc( +// testAccCheckUserExists("prismacloudcompute_users.test", &o), +// testAccCheckUserAttributes(&o, id, true), +// ), +// }, +// }, +// }) +// } -// if rs.Type != "prismacloudcompute_users" { -// continue -// } +// func testUsersExists(n string, o *user.User) resource.TestCheckFunc { +// return func(s *terraform.State) error { +// // return fmt.Errorf("What is the name: %s", o.UserId) -// if rs.Primary.ID != "" { -// name := rs.Primary.ID -// if err := user.Delete(client, name); err == nil { -// return fmt.Errorf("Object %q still exists", name) -// } -// } -// return nil +// rs, ok := s.RootModule().Resources[n] +// if !ok { +// return fmt.Errorf("Resource not found: %s", n) // } -// */ -// return nil -// } -// func testUsersConfig(id string) string { -// var buf bytes.Buffer -// buf.Grow(500) +// if rs.Primary.ID == "" { +// return fmt.Errorf("Object label Id is not set") +// } -// buf.WriteString(fmt.Sprintf(` -// resource "prismacloudcompute_users" "test" { -// name = %q -// }`, id)) +// client := testAccProvider.Meta().(*api.Client) +// lo, err := users.Get(*client) +// if err != nil { +// return fmt.Errorf("Error in get: %s", err) +// } +// *o = lo -// return buf.String() +// return nil +// } // } + +// // func testUsersAttributes(o *user.User, id string, learningDisabled bool) resource.TestCheckFunc { +// // return func(s *terraform.State) error { +// // if o.UserId != id { +// // return fmt.Errorf("\n\nUserId is %s, expected %s", o.UserId, id) +// // } else { +// // fmt.Printf("\n\nName is %s", o.UserId) +// // } + +// // if o.LearningDisabled != learningDisabled { +// // return fmt.Errorf("LearningDisabled is %t, expected %t", o.LearningDisabled, learningDisabled) +// // } + +// // return nil +// // } +// // } + +// // func testUsersDestroy(s *terraform.State) error { +// // /* client := testAccProvider.Meta().(*api.Client) + +// // for _, rs := range s.RootModule().Resources { + +// // if rs.Type != "prismacloudcompute_users" { +// // continue +// // } + +// // if rs.Primary.ID != "" { +// // name := rs.Primary.ID +// // if err := user.Delete(client, name); err == nil { +// // return fmt.Errorf("Object %q still exists", name) +// // } +// // } +// // return nil +// // } +// // */ +// // return nil +// // } + +// // func testUsersConfig(id string) string { +// // var buf bytes.Buffer +// // buf.Grow(500) + +// // buf.WriteString(fmt.Sprintf(` +// // resource "prismacloudcompute_users" "test" { +// // name = %q +// // }`, id)) + +// // return buf.String() +// // }