コード例 #1
0
    def test_expires_invalid_int(self):
        """Test case where an invalid type is passed for expires."""

        morsel = Morsel()
        morsel['expires'] = 100
        with pytest.raises(TypeError):
            morsel_to_cookie(morsel)
コード例 #2
0
ファイル: test_requests.py プロジェクト: RRedwards/requests
    def test_expires_invalid_int(self):
        """Test case where an invalid type is passed for expires."""

        morsel = Morsel()
        morsel["expires"] = 100
        with pytest.raises(TypeError):
            morsel_to_cookie(morsel)
コード例 #3
0
ファイル: test_requests.py プロジェクト: RRedwards/requests
    def test_expires_invalid_str(self):
        """Test case where an invalid string is input."""

        morsel = Morsel()
        morsel["expires"] = "woops"
        with pytest.raises(ValueError):
            morsel_to_cookie(morsel)
コード例 #4
0
ファイル: test_requests.py プロジェクト: RRedwards/requests
    def test_max_age_invalid_str(self):
        """Test case where a invalid max age is passed."""

        morsel = Morsel()
        morsel["max-age"] = "woops"
        with pytest.raises(TypeError):
            morsel_to_cookie(morsel)
コード例 #5
0
    def test_expires_invalid_str(self):
        """Test case where an invalid string is input."""

        morsel = Morsel()
        morsel['expires'] = 'woops'
        with pytest.raises(ValueError):
            morsel_to_cookie(morsel)
コード例 #6
0
    def test_max_age_invalid_str(self):
        """Test case where a invalid max age is passed."""

        morsel = Morsel()
        morsel['max-age'] = 'woops'
        with pytest.raises(TypeError):
            morsel_to_cookie(morsel)
コード例 #7
0
    def test_expires_valid_str(self):
        """Test case where we convert expires from string time."""

        morsel = Morsel()
        morsel['expires'] = 'Thu, 01-Jan-1970 00:00:01 GMT'
        cookie = morsel_to_cookie(morsel)
        assert cookie.expires == 1
コード例 #8
0
def requests_1_sde(one_input):
    try:
        ipt_data = str(one_input)
    except UnicodeDecodeError:
        sys.exit(0)

    C = SimpleCookie(ipt_data)
    for morsel in C.values():
        cookie = morsel_to_cookie(morsel)
        print(cookie)

    ipt_data2 = "{}={}; path=/; domain=.test.com".format(ipt_data, ipt_data)
    C = SimpleCookie(ipt_data2)
    for morsel in C.values():
        cookie = morsel_to_cookie(morsel)
        print(cookie)
コード例 #9
0
    def test_expires_none(self):
        """Test case where expires is None."""

        morsel = Morsel()
        morsel['expires'] = None
        cookie = morsel_to_cookie(morsel)
        assert cookie.expires is None
コード例 #10
0
    def test_max_age_valid_int(self):
        """Test case where a valid max age in seconds is passed."""

        morsel = Morsel()
        morsel['max-age'] = 60
        cookie = morsel_to_cookie(morsel)
        assert isinstance(cookie.expires, int)
コード例 #11
0
ファイル: test_requests.py プロジェクト: RRedwards/requests
    def test_max_age_valid_int(self):
        """Test case where a valid max age in seconds is passed."""

        morsel = Morsel()
        morsel["max-age"] = 60
        cookie = morsel_to_cookie(morsel)
        assert isinstance(cookie.expires, int)
コード例 #12
0
ファイル: test_requests.py プロジェクト: RRedwards/requests
    def test_expires_none(self):
        """Test case where expires is None."""

        morsel = Morsel()
        morsel["expires"] = None
        cookie = morsel_to_cookie(morsel)
        assert cookie.expires is None
コード例 #13
0
ファイル: test_requests.py プロジェクト: RRedwards/requests
    def test_expires_valid_str(self):
        """Test case where we convert expires from string time."""

        morsel = Morsel()
        morsel["expires"] = "Thu, 01-Jan-1970 00:00:01 GMT"
        cookie = morsel_to_cookie(morsel)
        assert cookie.expires == 1
コード例 #14
0
ファイル: pages.py プロジェクト: frankrousseau/weboob-modules
 def proceed(self):
     script = self.doc.xpath('//script/text()')[0]
     cookieStr = re.match('.*document\.cookie = "([^"]+)".*',
                          script, re.DOTALL).group(1)
     morsel = Cookie.Cookie(cookieStr).values()[0]
     self.browser.session.cookies.set_cookie(morsel_to_cookie(morsel))
     form = self.get_form()
     return form.submit()
コード例 #15
0
ファイル: pages.py プロジェクト: linura/weboob
 def proceed(self):
     script = self.doc.xpath('//script/text()')[0]
     cookieStr = re.match('.*document\.cookie = "([^"]+)".*', script,
                          re.DOTALL).group(1)
     morsel = Cookie.Cookie(cookieStr).values()[0]
     self.browser.session.cookies.set_cookie(morsel_to_cookie(morsel))
     form = self.get_form()
     return form.submit()
コード例 #16
0
def test_app_secure_cookies():
    cookies_view.set_secure_cookie('test', '内容测试')
    cookies_view.set_secure_cookie('test2', {'value': '内容测试'})
    cookies_view.finish(RETCODE.SUCCESS)

    cookies_jar = CookieJar()
    for k, v in cookies_view.response.cookies.items():
        cookies_jar.set_cookie(morsel_to_cookie(v))

    cookies_view.request.cookies = dict_from_cookiejar(cookies_jar)

    assert cookies_view.get_secure_cookie('test') == '内容测试'
    assert cookies_view.get_secure_cookie('test2') == {'value': '内容测试'}
コード例 #17
0
ファイル: test_requests.py プロジェクト: 503945930/requests
 def test_expires_invalid_int(self, value, exception):
     """Test case where an invalid type is passed for expires."""
     morsel = Morsel()
     morsel['expires'] = value
     with pytest.raises(exception):
         morsel_to_cookie(morsel)
コード例 #18
0
 def test_expires_invalid_int(self, value, exception):
     """Test case where an invalid type is passed for expires."""
     morsel = Morsel()
     morsel['expires'] = value
     with pytest.raises(exception):
         morsel_to_cookie(morsel)