Esempio n. 1
0
def test_get_document_writes():
    finder = finders.HtmlTreeUrlFinder(html)
    expected = {
        """document.write (unescape('<meta HTTP-EQUIV="REFRESH" CONTENT="0; url=http://domain.com/js.php">') ) ;""",
        """document.write (unescape('<meta HTTP-EQUIV="REFRESH" CONTENT="0; url=http://domain.com/js2.php">') ) ;""",
    }
    assert finder._get_document_writes() == expected
Esempio n. 2
0
def test_get_tag_attribute_values():
    finder = finders.HtmlTreeUrlFinder(html)
    expected = {
        "xmlns",
        "http://domain.com",
        "REFRESH",
        '0;url="meta"',
        "0; URL=meta2",
        "X-UA-Compatible",
        "IE=edge",
        "background",
        "action",
        "action2",
        "background-image: url('css');",
        "background-image: url('css2');",
        "href",
        "body strikeout",
        "obf",
        "href2",
        "src",
        "src2",
        "id",
        "id2",
    }
    assert finder._get_tag_attribute_values() == expected
Esempio n. 3
0
def test_get_document_write_contents():
    finder = finders.HtmlTreeUrlFinder(html)
    expected = {
        '<meta HTTP-EQUIV="REFRESH" CONTENT="0; url=http://domain.com/js.php">',
        '<meta HTTP-EQUIV="REFRESH" CONTENT="0; url=http://domain.com/js2.php">',
    }
    assert finder._get_document_write_contents() == expected
Esempio n. 4
0
def test_replace_href_value():
    this_html = '<html><body><a href="test">blah</a></body></html>'
    finder = finders.HtmlTreeUrlFinder(this_html)
    assert finder.tree_string == this_html

    href_values = finder._get_href_values()
    assert href_values == {"test"}

    assert finder.tree_string == '<html><body><a href="">blah</a></body></html>'
Esempio n. 5
0
def test_get_base_url_eligible_values():
    finder = finders.HtmlTreeUrlFinder(html)
    expected = {
        "http://domain.com",
        "action",
        "action2",
        "background",
        "css",
        "css2",
        "href",
        "href2",
        "src",
        "src2",
        "xmlns",
    }
    assert finder._get_base_url_eligible_values() == expected
Esempio n. 6
0
def test_get_srcset_values():
    this_html = """
<img src="http://domain2.com/image-small.png"
    srcset="http://domain2.com/image-small.png 320w,
        http://domain2.com/image-medium.png 800w,
        http://domain2.com/image-large.png 1200w"
    sizes="80vw"
    alt="Image description">
"""

    finder = finders.HtmlTreeUrlFinder(this_html)
    assert finder._get_srcset_values() == {
        "http://domain2.com/image-small.png",
        "http://domain2.com/image-medium.png",
        "http://domain2.com/image-large.png",
    }
Esempio n. 7
0
def test_get_css_url_values():
    finder = finders.HtmlTreeUrlFinder(html)
    assert finder._get_css_url_values() == {"css", "css2"}
Esempio n. 8
0
def test_get_base_url_from_html():
    finder = finders.HtmlTreeUrlFinder(html)
    assert finder._get_base_url_from_html() == "http://domain.com"
Esempio n. 9
0
def test_get_background_values():
    finder = finders.HtmlTreeUrlFinder(html)
    assert finder._get_background_values() == {"background"}
Esempio n. 10
0
def test_get_action_values():
    finder = finders.HtmlTreeUrlFinder(html)
    assert finder._get_action_values() == {"action", "action2"}
Esempio n. 11
0
def test_pick_base_url():
    finder = finders.HtmlTreeUrlFinder(html, base_url="http://domain2.com")
    assert finder.base_url == "http://domain.com"
Esempio n. 12
0
def test_get_xmlns_values():
    finder = finders.HtmlTreeUrlFinder(html)
    assert finder._get_xmlns_values() == {"xmlns"}
Esempio n. 13
0
def test_get_visible_text():
    finder = finders.HtmlTreeUrlFinder(html)
    expected = "vis"
    assert finder._get_visible_text() == expected
Esempio n. 14
0
def test_get_src_values():
    finder = finders.HtmlTreeUrlFinder(html)
    assert finder._get_src_values() == {"src", "src2"}
Esempio n. 15
0
def test_get_meta_refresh_values():
    finder = finders.HtmlTreeUrlFinder(html)
    expected = {"meta", "meta2"}
    assert finder._get_meta_refresh_values() == expected
Esempio n. 16
0
def test_get_href_values():
    finder = finders.HtmlTreeUrlFinder(html)
    assert finder._get_href_values() == {"http://domain.com", "href", "href2"}