Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF Generate - Handling unsupported custom domains error #854

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/cli/terraform_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"context"
"strings"

"github.com/auth0/go-auth0/management"
"github.com/google/uuid"
Expand Down Expand Up @@ -202,6 +203,10 @@ func (f *customDomainResourceFetcher) FetchData(ctx context.Context) (importData

customDomains, err := f.api.CustomDomain.List(ctx)
if err != nil {
if strings.Contains(err.Error(), "The account is not allowed to perform this operation, please contact our support team") {
return data, nil
}

return nil, err
}

Expand Down
20 changes: 20 additions & 0 deletions internal/cli/terraform_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,26 @@ func TestCustomDomainResourceFetcher_FetchData(t *testing.T) {
_, err := fetcher.FetchData(context.Background())
assert.EqualError(t, err, "failed to list custom domains")
})

t.Run("it returns empty set error if unsupported feature error occurs", func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

customDomainAPI := mock.NewMockCustomDomainAPI(ctrl)
customDomainAPI.EXPECT().
List(gomock.Any()).
Return(nil, fmt.Errorf("403 Forbidden: The account is not allowed to perform this operation, please contact our support team"))

fetcher := customDomainResourceFetcher{
api: &auth0.API{
CustomDomain: customDomainAPI,
},
}

data, err := fetcher.FetchData(context.Background())
assert.NoError(t, err)
assert.Len(t, data, 0)
})
}

func TestGuardianResourceFetcher_FetchData(t *testing.T) {
Expand Down
Loading