|
@@ -14965,6 +14965,13 @@ func TestUserAPIKey(t *testing.T) {
|
|
|
apiKey, _, err = httpdtest.AddAPIKey(apiKey, http.StatusCreated)
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
+ adminAPIKey := dataprovider.APIKey{
|
|
|
+ Name: "testadminkey",
|
|
|
+ Scope: dataprovider.APIKeyScopeAdmin,
|
|
|
+ }
|
|
|
+ adminAPIKey, _, err = httpdtest.AddAPIKey(adminAPIKey, http.StatusCreated)
|
|
|
+ assert.NoError(t, err)
|
|
|
+
|
|
|
body := new(bytes.Buffer)
|
|
|
writer := multipart.NewWriter(body)
|
|
|
part, err := writer.CreateFormFile("filenames", "filenametest")
|
|
@@ -14993,6 +15000,12 @@ func TestUserAPIKey(t *testing.T) {
|
|
|
assert.NoError(t, err)
|
|
|
assert.Len(t, dirEntries, 1)
|
|
|
|
|
|
+ req, err = http.NewRequest(http.MethodGet, userDirsPath, nil)
|
|
|
+ assert.NoError(t, err)
|
|
|
+ setAPIKeyForReq(req, adminAPIKey.Key, user.Username)
|
|
|
+ rr = executeRequest(req)
|
|
|
+ checkResponseCode(t, http.StatusForbidden, rr)
|
|
|
+
|
|
|
user.Status = 0
|
|
|
user, _, err = httpdtest.UpdateUser(user, http.StatusOK, "")
|
|
|
assert.NoError(t, err)
|
|
@@ -15069,6 +15082,9 @@ func TestUserAPIKey(t *testing.T) {
|
|
|
|
|
|
_, err = httpdtest.RemoveAPIKey(apiKeyNew, http.StatusOK)
|
|
|
assert.NoError(t, err)
|
|
|
+
|
|
|
+ _, err = httpdtest.RemoveAPIKey(adminAPIKey, http.StatusOK)
|
|
|
+ assert.NoError(t, err)
|
|
|
}
|
|
|
|
|
|
func TestWebClientViewPDF(t *testing.T) {
|