Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/schollz/pro…
Browse files Browse the repository at this point in the history
…gressbar/v3-3.17.1
  • Loading branch information
duedares-rvj authored Dec 19, 2024
2 parents c59a643 + 15ff967 commit 9296bf5
Show file tree
Hide file tree
Showing 8 changed files with 304 additions and 155 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

# [v.1.7.0](https://github.com/auth0/auth0-cli/tree/v1.7.0) (Dec 9, 2024))

[Full Changelog](https://github.com/auth0/auth0-cli/compare/v1.6.1...v1.7.0)

### Added

- Support for importing `auth0_prompt_screen_renderer` terraform resource [#1106]

### Fixed

- For `ul login` added check to filter and identify only support partials. [#1107]

# [v1.6.1](https://github.com/auth0/auth0-cli/tree/v1.6.1) (Oct 31, 2024)

[Full Changelog](https://github.com/auth0/auth0-cli/compare/v1.6.0...v1.6.1)
Expand Down Expand Up @@ -327,6 +339,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updating of action triggers which inevitably results in error [#597]

[unreleased]: https://github.com/auth0/auth0-cli/compare/v1.5.1...HEAD
[#1107]: https://github.com/auth0/auth0-cli/issues/1107
[#1106]: https://github.com/auth0/auth0-cli/issues/1106
[#1099]: https://github.com/auth0/auth0-cli/issues/1099
[#1098]: https://github.com/auth0/auth0-cli/issues/1098
[#1091]: https://github.com/auth0/auth0-cli/issues/1091
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/data/universal-login/prompt-screen-settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"__doc1__": "The rendering_mode could be either advanced or standard... default_head_tags_disabled is a toggle to override Universal Login default head tags... context_configuration are the set of Context values to make available(Refer docs for the possible values)... head_tags are the array of head tags)..",
"__doc2__": "Note1: To update the rendering_mode to standard, only parse the rendering_mode field; no other fields are needed.",
"__doc2__": "Note1: while updating the rendering_mode to standard, only the rendering_mode field gets updated, the other fields shall not be updated.",
"__doc3__": "Note2: head_tags must contain at least one script tag",
"__doc4__": "Only the declared fields will be updated, Rest stays same.",
"__doc5__": "See the docs for possible values",
"__doc4__": "Only the declared fields get updated, rest stays same",
"__doc5__": "See https://auth0.com/docs/customize/login-pages/advanced-customizations/getting-started/configure-acul-screens for all possible values for each field",

"rendering_mode": "advanced",
"default_head_tags": false,
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/prompts_custom_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
const (
textDocsKey = "__doc__"
textDocsURL = "https://auth0.com/docs/customize/universal-login-pages/customize-login-text-prompts"
textLocalesURL = "https://cdn.auth0.com/ulp/react-components/1.66.3/languages/%s/prompts.json"
textLocalesURL = "https://cdn.auth0.com/ulp/react-components/1.102.1/languages/%s/prompts.json"
textLanguageDefault = "en"
)

Expand Down
12 changes: 9 additions & 3 deletions internal/cli/terraform_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,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 Expand Up @@ -471,7 +477,7 @@ func (f *promptScreenRendererResourceFetcher) FetchData(ctx context.Context) (im
_, err := f.api.Prompt.ReadRendering(ctx, "login-id", "login-id")
// Checking for the ACUL enabled feature.
if err != nil {
if strings.Contains(err.Error(), "This tenant does not have ACUL enabled") {
if strings.Contains(err.Error(), "403 Forbidden: This tenant does not have Advanced Customizations enabled") {
return nil, nil
}

Expand Down
86 changes: 86 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 Expand Up @@ -1288,6 +1308,72 @@ func TestPromptProviderResourceFetcher_FetchData(t *testing.T) {
})
}

func TestPromptScreenRendererResourceFetcher_FetchData(t *testing.T) {
t.Run("it successfully renders the prompts & screen settings import data", func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

promptAPI := mock.NewMockPromptAPI(ctrl)
promptAPI.EXPECT().ReadRendering(gomock.Any(), management.PromptType("login-id"), management.ScreenName("login-id")).
Return(&management.PromptRendering{}, nil)

fetcher := promptScreenRendererResourceFetcher{
api: &auth0.API{
Prompt: promptAPI,
},
}

expectedData := importDataList{}
for promptType, screenNames := range ScreenPromptMap {
for _, screenName := range screenNames {
expectedData = append(expectedData, importDataItem{
ResourceName: "auth0_prompt_screen_renderer." + sanitizeResourceName(promptType+"_"+screenName),
ImportID: promptType + ":" + screenName,
})
}
}

data, err := fetcher.FetchData(context.Background())
assert.NoError(t, err)
assert.ElementsMatch(t, expectedData, data)
})
t.Run("it handles error, even if tenant does not have ACUL enabled", func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

promptAPI := mock.NewMockPromptAPI(ctrl)
promptAPI.EXPECT().ReadRendering(gomock.Any(), management.PromptType("login-id"), management.ScreenName("login-id")).
Return(&management.PromptRendering{}, fmt.Errorf("403 Forbidden: This tenant does not have Advanced Customizations enabled"))

fetcher := promptScreenRendererResourceFetcher{
api: &auth0.API{
Prompt: promptAPI,
},
}

data, err := fetcher.FetchData(context.Background())
assert.NoError(t, err)
assert.Len(t, data, 0)
})
t.Run("it returns error, if the API call fails", func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

promptAPI := mock.NewMockPromptAPI(ctrl)
promptAPI.EXPECT().ReadRendering(gomock.Any(), management.PromptType("login-id"), management.ScreenName("login-id")).
Return(&management.PromptRendering{}, fmt.Errorf("failed to read rendering settings"))

fetcher := promptScreenRendererResourceFetcher{
api: &auth0.API{
Prompt: promptAPI,
},
}

_, err := fetcher.FetchData(context.Background())
assert.EqualError(t, err, "failed to read rendering settings")
})
}

func TestPromptCustomTextResourceFetcher_FetchData(t *testing.T) {
t.Run("it successfully retrieves custom text prompts data", func(t *testing.T) {
ctrl := gomock.NewController(t)
Expand Down
Loading

0 comments on commit 9296bf5

Please sign in to comment.