mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
feat(client): add custom_js
field to Go API client
This commit is contained in:
parent
e07203ad46
commit
600dea6ce5
2 changed files with 31 additions and 0 deletions
|
@ -27,6 +27,7 @@ type User struct {
|
||||||
EntryDirection string `json:"entry_sorting_direction"`
|
EntryDirection string `json:"entry_sorting_direction"`
|
||||||
EntryOrder string `json:"entry_sorting_order"`
|
EntryOrder string `json:"entry_sorting_order"`
|
||||||
Stylesheet string `json:"stylesheet"`
|
Stylesheet string `json:"stylesheet"`
|
||||||
|
CustomJS string `json:"custom_js"`
|
||||||
GoogleID string `json:"google_id"`
|
GoogleID string `json:"google_id"`
|
||||||
OpenIDConnectID string `json:"openid_connect_id"`
|
OpenIDConnectID string `json:"openid_connect_id"`
|
||||||
EntriesPerPage int `json:"entries_per_page"`
|
EntriesPerPage int `json:"entries_per_page"`
|
||||||
|
@ -70,6 +71,7 @@ type UserModificationRequest struct {
|
||||||
EntryDirection *string `json:"entry_sorting_direction"`
|
EntryDirection *string `json:"entry_sorting_direction"`
|
||||||
EntryOrder *string `json:"entry_sorting_order"`
|
EntryOrder *string `json:"entry_sorting_order"`
|
||||||
Stylesheet *string `json:"stylesheet"`
|
Stylesheet *string `json:"stylesheet"`
|
||||||
|
CustomJS *string `json:"custom_js"`
|
||||||
GoogleID *string `json:"google_id"`
|
GoogleID *string `json:"google_id"`
|
||||||
OpenIDConnectID *string `json:"openid_connect_id"`
|
OpenIDConnectID *string `json:"openid_connect_id"`
|
||||||
EntriesPerPage *int `json:"entries_per_page"`
|
EntriesPerPage *int `json:"entries_per_page"`
|
||||||
|
|
|
@ -592,6 +592,35 @@ func TestUpdateUserEndpointByChangingDefaultTheme(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUpdateUserEndpointByChangingCustomJS(t *testing.T) {
|
||||||
|
testConfig := newIntegrationTestConfig()
|
||||||
|
if !testConfig.isConfigured() {
|
||||||
|
t.Skip(skipIntegrationTestsMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
adminClient := miniflux.NewClient(testConfig.testBaseURL, testConfig.testAdminUsername, testConfig.testAdminPassword)
|
||||||
|
regularTestUser, err := adminClient.CreateUser(testConfig.genRandomUsername(), testConfig.testRegularPassword, false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer adminClient.DeleteUser(regularTestUser.ID)
|
||||||
|
|
||||||
|
regularUserClient := miniflux.NewClient(testConfig.testBaseURL, regularTestUser.Username, testConfig.testRegularPassword)
|
||||||
|
|
||||||
|
userUpdateRequest := &miniflux.UserModificationRequest{
|
||||||
|
CustomJS: miniflux.SetOptionalField("alert('Hello, World!');"),
|
||||||
|
}
|
||||||
|
|
||||||
|
updatedUser, err := regularUserClient.UpdateUser(regularTestUser.ID, userUpdateRequest)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if updatedUser.CustomJS != "alert('Hello, World!');" {
|
||||||
|
t.Fatalf(`Invalid custom JS, got %q`, updatedUser.CustomJS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestUpdateUserEndpointByChangingDefaultThemeToInvalidValue(t *testing.T) {
|
func TestUpdateUserEndpointByChangingDefaultThemeToInvalidValue(t *testing.T) {
|
||||||
testConfig := newIntegrationTestConfig()
|
testConfig := newIntegrationTestConfig()
|
||||||
if !testConfig.isConfigured() {
|
if !testConfig.isConfigured() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue