Skip to content

Commit

Permalink
debug recorder (remove this commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
acwest committed Sep 26, 2024
1 parent 4a2f29d commit 32d33df
Show file tree
Hide file tree
Showing 10 changed files with 1,096 additions and 105 deletions.
15 changes: 15 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,20 @@ issues:
- path: "(.+)_test.go"
linters:
- gosec
- path: "internal/go-vcr.v3"
linters:
- unused
- gofmt
- staticcheck
- revive
- godot
- whitespace
- goimports
- gosimple
- errcheck
- unconvert
- gocritic
- gosec
- gocyclo
exclude:
- "should have a package comment"
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ test-unit: ## Run unit tests. To run a specific test, pass the FILTER var. Usage

test-acc: ## Run acceptance tests with http recordings. To run a specific test, pass the FILTER var. Usage `make test-acc FILTER="TestAccResourceServer`
${call print, "Running acceptance tests with http recordings"}
@AUTH0_HTTP_RECORDINGS=on \
@terraform version; \
AUTH0_HTTP_RECORDINGS=on \
AUTH0_DOMAIN=terraform-provider-auth0-dev.eu.auth0.com \
TF_LOG=DEBUG \
TF_ACC=1 \
go test \
-v \
Expand Down
2 changes: 1 addition & 1 deletion internal/acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"gopkg.in/dnaeon/go-vcr.v3/recorder"

"github.com/auth0/terraform-provider-auth0/internal/config"
"github.com/auth0/terraform-provider-auth0/internal/go-vcr.v3/recorder"
"github.com/auth0/terraform-provider-auth0/internal/provider"
)

Expand Down
5 changes: 3 additions & 2 deletions internal/acctest/http_recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
"github.com/auth0/go-auth0"
"github.com/auth0/go-auth0/management"
"github.com/stretchr/testify/require"
"gopkg.in/dnaeon/go-vcr.v3/cassette"
"gopkg.in/dnaeon/go-vcr.v3/recorder"

"github.com/auth0/terraform-provider-auth0/internal/go-vcr.v3/cassette"
"github.com/auth0/terraform-provider-auth0/internal/go-vcr.v3/recorder"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion internal/auth0/organization/resource_client_grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ resource "auth0_organization" "my_organization" {
}
resource "auth0_resource_server" "new_resource_server" {
depends_on = [ auth0_organization.my_organization ]
name = "Example API"
identifier = "https://api.travel00123.com/"
}
resource "auth0_client" "my_test_client"{
depends_on = [ auth0_organization.my_organization, auth0_client.my_test_client ]
depends_on = [ auth0_organization.my_organization, auth0_resource_server.new_resource_server ]
name = "test_client"
organization_usage = "allow"
default_organization {
Expand Down
7 changes: 7 additions & 0 deletions internal/auth0/resourceserver/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resourceserver
import (
"context"
"fmt"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -122,6 +123,7 @@ func NewResource() *schema.Resource {
}

func createResourceServer(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics {
fmt.Printf("DEBUG: CRAIG: createResourceServer\n")
api := meta.(*config.Config).GetAPI()

resourceServer := expandResourceServer(data)
Expand All @@ -132,10 +134,13 @@ func createResourceServer(ctx context.Context, data *schema.ResourceData, meta i

data.SetId(resourceServer.GetID())

time.Sleep(200 * time.Millisecond)

return readResourceServer(ctx, data, meta)
}

func readResourceServer(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics {
fmt.Printf("DEBUG: CRAIG: readResourceServer\n")
api := meta.(*config.Config).GetAPI()

resourceServer, err := api.ResourceServer.Read(ctx, data.Id())
Expand All @@ -151,6 +156,7 @@ func readResourceServer(ctx context.Context, data *schema.ResourceData, meta int
}

func updateResourceServer(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics {
fmt.Printf("DEBUG: CRAIG: updateResourceServer\n")
api := meta.(*config.Config).GetAPI()

resourceServer := expandResourceServer(data)
Expand All @@ -163,6 +169,7 @@ func updateResourceServer(ctx context.Context, data *schema.ResourceData, meta i
}

func deleteResourceServer(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics {
fmt.Printf("DEBUG: CRAIG: deleteResourceServer\n")
if resourceServerIsAuth0ManagementAPI(data.GetRawState()) {
return nil
}
Expand Down
24 changes: 24 additions & 0 deletions internal/go-vcr.v3/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2015-2022 Marin Atanasov Nikolov <dnaeon@gmail.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit 32d33df

Please sign in to comment.