0

I'm looking for some help. It is already several days I've looked for solution without any success.

I need to launch load test with locust on my nextcloud webpages. I have been able to login and load the "/" page successfully.

I failed to load other pages as "/apps/dashboard/", "/apps/deck/" or "/logout", and I receive the error message '401 Client Error:unauthorized for url: /apps/dashboard'

So it seems I'm logging out before I can load "/apps/dashboard"

Below is my code

import time
from locust import HttpUser, task, between

class StartUserBehavior(HttpUser):

    def on_start(self):
        self.login()

    def login(self):

        response = self.client.post('/login', json={'username':'admin', 'password':'adminpasswd'})
        if response.status_code == 200:
            print('[+]Connection succeeded')
        else:
            print('[-]Connection failed')
            print('[-]Error :', response.status_code)
    
    def on_stop(self):
        response = self.client.get('/logout')
        if response.status_code == 200:
            print('[+]Disconnection succeeded')
        else:
            print('[-]Disconnection failed')
            print('[-]Error :', response.status_code)

    @task
    def view_pages(self):
        self.client.get('/')
        time.sleep(5)
        result = self.client.get('/apps/dashboard')
        time.sleep(5)

some check I made:

  • The webpages are correct
  • I am logged as administrator
  • I can login with success
  • I received a 401 error for all pages except "/login" and "/" which are freely accessible.

Any help would be appreciated

Fangshi
  • 1
  • 1
  • Do you wanna me to take a look and try to figure out a solution for your case? I'm open for this business, send me an email to start looking at this with more details of how to test your site. You could see the email in my profile – aekis.dev Jul 20 '23 at 23:57
  • Hello @aekis.dev. Thanks for your offer. I am just a trainee who is trying to figure out why it is not working as I was expecting. Thanks for your comprehension. – Fangshi Jul 21 '23 at 05:17
  • Continuing my research, I found that an authentication token might be needed to get the access to the pages following the post: https://stackoverflow.com/questions/76325123/locust-load-testing-in-python-requires-login-to-website-any-advise – Fangshi Jul 24 '23 at 11:28
  • Continuing my research, A link to better understand how token works for nextcloud: https://stackoverflow.com/questions/56089821/sharing-nextcloud-authentication-with-custom-web-application – Fangshi Aug 01 '23 at 05:45

0 Answers0