summaryrefslogtreecommitdiff
path: root/test/tc_httpfetcher.rb
blob: d44b3eea17a6f65d67f1734d6759ef8608731fcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/ruby

$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')

require 'test/unit'
require 'feed2imap/httpfetcher'

class HttpFetcherTest < Test::Unit::TestCase
  def test_get_https
    s = ''
    assert_nothing_raised do
      s = HTTPFetcher::fetch('https://linuxfr.org/pub/', Time::at(0))
    end
    assert(s.length > 20)
  end

  def test_get_http
  
  end

  def test_get_httpnotmodif
    s = 'aaa'
    assert_nothing_raised do
      s = HTTPFetcher::fetch('http://www.lucas-nussbaum.net/feed2imap_tests/notmodified.php', Time::new())
    end
    assert_nil(s)
  end

  def test_get_redir1
    s = 'aaa'
    assert_nothing_raised do
      s = HTTPFetcher::fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR}", Time::at(0))
    end
    assert_equal('OK', s)
  end

  def test_get_redir2
    s = ''
    assert_raise(RuntimeError) do
      s = HTTPFetcher::fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR + 1}", Time::at(0))
    end
  end

  def test_httpauth
    s = ''
    assert_nothing_raised do
      s = HTTPFetcher::fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php", Time::at(0))
    end
    assert_equal("Login: aaa / Password: bbb \n", s)
  end

  def test_redirauth
    s = ''
    assert_nothing_raised do
      s = HTTPFetcher::fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php?redir=1", Time::at(0))
    end
    assert_equal("Login: aaa / Password: bbb \n", s)
  end

  def test_notfound
    s = ''
    assert_raises(RuntimeError) do
      s = HTTPFetcher::fetch("http://ensilinx1.imag.fr/~lucas/notfound.html", Time::at(0))
    end
  end
end
deletions'>-3/+88 2020-04-19Started IMAP connectionRené 'Necoro' Neumann4-0/+152 2020-04-19Use our own logger for debug for convenience sakeRené 'Necoro' Neumann1-2/+3 2020-04-19Fix debug logging m(René 'Necoro' Neumann1-2/+2 2020-04-19Rename util.go to log.go. Add verbose modeRené 'Necoro' Neumann4-24/+54 2020-04-19Clean go.modRené 'Necoro' Neumann2-3/+0 2020-04-19Do not print the parsedCfg anymoreRené 'Necoro' Neumann1-1/+1 2020-04-19Increase go-version to 1.14René 'Necoro' Neumann1-2/+2 2020-04-19CI: go vetRené 'Necoro' Neumann1-0/+3 2020-04-19Fetching and parsing the feedsRené 'Necoro' Neumann5-4/+113 2020-04-19Ignore all config*.ymlRené 'Necoro' Neumann1-1/+1