MCPcopy
hub / github.com/pocketbase/pocketbase / TestSettingsSet

Function TestSettingsSet

apis/settings_test.go:95–258  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestSettingsSet(t *testing.T) {
96 t.Parallel()
97
98 validData := `{
99 "meta":{"appName":"update_test"},
100 "smtp":{"password": "new_smtp_password"},
101 "s3":{"secret": "new_s3_secret"},
102 "backups":{"s3":{"secret":"new_backups_s3_secret"}}
103 }`
104
105 scenarios := []tests.ApiScenario{
106 {
107 Name: "unauthorized",
108 Method: http.MethodPatch,
109 URL: "/api/settings",
110 Body: strings.NewReader(validData),
111 ExpectedStatus: 401,
112 ExpectedContent: []string{`"data":{}`},
113 ExpectedEvents: map[string]int{"*": 0},
114 },
115 {
116 Name: "authorized as regular user",
117 Method: http.MethodPatch,
118 URL: "/api/settings",
119 Body: strings.NewReader(validData),
120 Headers: map[string]string{
121 "Authorization": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6IjRxMXhsY2xtZmxva3UzMyIsInR5cGUiOiJhdXRoIiwiY29sbGVjdGlvbklkIjoiX3BiX3VzZXJzX2F1dGhfIiwiZXhwIjoyNTI0NjA0NDYxLCJyZWZyZXNoYWJsZSI6dHJ1ZX0.ZT3F0Z3iM-xbGgSG3LEKiEzHrPHr8t8IuHLZGGNuxLo",
122 },
123 ExpectedStatus: 403,
124 ExpectedContent: []string{`"data":{}`},
125 ExpectedEvents: map[string]int{"*": 0},
126 },
127 {
128 Name: "authorized as superuser submitting empty data",
129 Method: http.MethodPatch,
130 URL: "/api/settings",
131 Body: strings.NewReader(``),
132 Headers: map[string]string{
133 "Authorization": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6InN5d2JoZWNuaDQ2cmhtMCIsInR5cGUiOiJhdXRoIiwiY29sbGVjdGlvbklkIjoicGJjXzMxNDI2MzU4MjMiLCJleHAiOjI1MjQ2MDQ0NjEsInJlZnJlc2hhYmxlIjp0cnVlfQ.UXgO3j-0BumcugrFjbd7j0M4MQvbrLggLlcu_YNGjoY",
134 },
135 ExpectedStatus: 200,
136 ExpectedContent: []string{
137 `"meta":{`,
138 `"logs":{`,
139 `"smtp":{`,
140 `"s3":{`,
141 `"backups":{`,
142 `"batch":{`,
143 },
144 ExpectedEvents: map[string]int{
145 "*": 0,
146 "OnSettingsUpdateRequest": 1,
147 "OnModelUpdate": 1,
148 "OnModelUpdateExecute": 1,
149 "OnModelAfterUpdateSuccess": 1,
150 "OnModelValidate": 1,
151 "OnSettingsReload": 1,
152 },

Callers

nothing calls this directly

Calls 8

NewReaderMethod · 0.80
BadRequestErrorMethod · 0.80
TestMethod · 0.80
SettingsMethod · 0.65
RunInTransactionMethod · 0.65
NextMethod · 0.65
BindFuncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…