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

fix(terraform): Handle error when custom domain is not enabled #1103

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions internal/cli/terraform_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,16 @@ 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
errNotEnabled := []string{
"The account is not allowed to perform this operation, please contact our support team",
"There must be a verified credit card on file to perform this operation",
}

for _, e := range errNotEnabled {
if strings.Contains(err.Error(), e) {
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 @@ -561,6 +561,26 @@ func TestCustomDomainResourceFetcher_FetchData(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, data, 0)
})

t.Run("it returns empty set error if no verified CC 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: There must be a verified credit card on file to perform this operation"))

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

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

func TestFormResourceFetcher_FetchData(t *testing.T) {
Expand Down