[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] Implementing draft to update RFC6265
From: |
Tim Ruehsen |
Subject: |
Re: [Bug-wget] Implementing draft to update RFC6265 |
Date: |
Mon, 01 Feb 2016 17:13:09 +0100 |
User-agent: |
KMail/4.14.10 (Linux/4.3.0-1-amd64; KDE/4.14.14; x86_64; ; ) |
On Sunday 31 January 2016 18:02:31 Darshit Shah wrote:
> On 31 January 2016 at 17:55, Ander Juaristi <address@hidden> wrote:
> > On 01/30/2016 09:31 PM, Kushagra Singh wrote:
> >> Hi,
> >>
> >> I'm a bit stuck while writing tests. How do I test the fact that a secure
> >> only cookie does not get saved over an insecure connection? Even if the
> >> cookie gets saved, it will not be transmitted over an insecure connection
> >> (cookie_matches_url() ensures that). So even though I can see in the log
> >> that the cookie is not saved, I can't figure out how exactly to test that
> >> in the test suite, since I cannot check using RejectHeader. Please find
> >> attached the test I have written.
> >
> > I've tried passing '--save-cookies=mycookies.wget', which creates a new
> > file in the test's directory, and then adding that file to the
> > 'ExpectedDownloadedFiles' list, for Wget to check if it's there. The
> > problem is the content check always fails, because Wget introduces
> > comments at the top of the cookie file that include the time and date,
> > and thus the test always fails saying that the contents don't match.
> >
> > I guess the solution here would be to create a hook and test that a cookie
> > file has been created, which has nothing but the initial comments.
> >
> > I don't know if that would be possible. @Darshit?
>
> Yes, a new hook for that would be possible. Should not be too hard, I
> would suggest a specific ExpectedCookieFile hook, that ignores the
> comment line and then tests for expected cookies in that file.
> It increases the number of specific hooks we maintain, but seems like
> the best idea to me. This could in fact be used to simplify some of
> the cookie tests which currently use RejectHeader, and could also test
> for session cookies correctly.
Instead having specialized hooks, why not giving allowing a function to
'ExpectedFiles' that can do any modification. I am not very python affine, but
somethin like this could work:
diff --git a/testenv/conf/expected_files.py b/testenv/conf/expected_files.py
index 5362771..c9a333f 100644
--- a/testenv/conf/expected_files.py
+++ b/testenv/conf/expected_files.py
@@ -17,7 +17,10 @@ files are found, else returns gracefully.
@hook()
class ExpectedFiles:
def __init__(self, expected_fs):
- self.expected_fs = expected_fs
+ if callable(expected_fs):
+ self.expected_fs = expected_fs()
+ else:
+ self.expected_fs = expected_fs
@staticmethod
def gen_local_fs_snapshot():
Not, in your test you can define a function that e.g. calls "grep -v '^#'
filename > filename-stripped" and returns a modified ExpectedFiles list.
In the test you define
def postfunc():
... remove the comments ...
return [WgetFile ("StrippedFile", StrippedFile)]
post_test = {
"ExpectedFiles" : postfunc,
"ExpectedRetcode" : ExpectedReturnCode
}
(Please feel free to fine-tune)
WDYT ?
Tim
- Re: [Bug-wget] Implementing draft to update RFC6265,
Tim Ruehsen <=
- Re: [Bug-wget] Implementing draft to update RFC6265, Tim Rühsen, 2016/02/01
- Re: [Bug-wget] Implementing draft to update RFC6265, Darshit Shah, 2016/02/03
- Re: [Bug-wget] Implementing draft to update RFC6265, Kushagra Singh, 2016/02/03
- Re: [Bug-wget] Implementing draft to update RFC6265, Darshit Shah, 2016/02/03
- Re: [Bug-wget] Implementing draft to update RFC6265, Kushagra Singh, 2016/02/08
- Re: [Bug-wget] Implementing draft to update RFC6265, Kushagra Singh, 2016/02/08
- Re: [Bug-wget] Implementing draft to update RFC6265, Kushagra Singh, 2016/02/10
- Re: [Bug-wget] Implementing draft to update RFC6265, Darshit Shah, 2016/02/11
- Re: [Bug-wget] Implementing draft to update RFC6265, Kushagra Singh, 2016/02/13