How to get wget to fail to fetch a password-protected URL after a previous success?

How to get wget to fail to fetch a password-protected URL after a previous success?

Shlomi Fish shlomif at shlomifish.org
Mon Dec 19 05:37:30 IST 2022


Hi Omer!

On Mon, 19 Dec 2022 03:57:25 +0200
Omer Zak <w1 at zak.co.il> wrote:

> I am writing regression tests to test that a website continues to
> behave the same after moving to another host.
> 
> Among other things, I want to test that a password-protected area in
> the website continues to work as expected, protecting its contents.
> 
> I am trying to test as follows.
> 
> wget ...other options... URL
>             # no passwords - expected to fail
> wget --user=wrong --password=wrong ...other options... URL
>             # expected to fail
> wget --user=correct --password=correct ...other options... URL
>             # expected to succeed
> 
> However after 1st time the correct user+password are presented,
> subsequent wget's to the same URL do not fail.
> 

I suspect the stale cache is on the webservice or on a proxy. Also note
that python3 has requests.py:

https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ_with_ToC__generated.md#how-can-i-write-code-to-perform-operations-on-web-sites-for-me-that-otherwise-should-be-done-manually

(short url: https://is.gd/ExAHTa )

> I Googled but found nothing useful.
> My version of wget is: GNU Wget 1.21 built on linux-gnu.
> (there is more information, will be provided if relevant)
> 
> At the suggestion of:
> https://stackoverflow.com/questions/35076334/dd-wrt-wget-returns-a-cached-file
> I tried:
> wget -p --no-http-keep-alive --no-cache --no-cookies \
>         --user=whatever --password=whatever
>         --no-host-directories URL
> Even this did not fail.
> 
> There is no obvious place in the filesystem where wget might cache its
> credentials.
> 
> How can I get wget to fail to fetch a password-protected web resource
> (HTTP 403 Forbidden) after it succeeded in fetching the same resource
> previously?
> 
> Thanks,
> --- Omer Zak
> 
> 



-- 

Shlomi Fish       https://www.shlomifish.org/
https://www.shlomifish.org/open-source/resources/tech-tips/

Ever notice that even the busiest people are never too busy to tell you
just how busy they are?
    — Source unknown, taken from Linux’s fortune-mod

Please reply to list if it's a mailing list post - https://shlom.in/reply .



More information about the Linux-il mailing list