opticon 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class Opticon::HTTPTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @test_uri = URI.parse("http://google.com")
7
+ @test_https_uri = URI.parse("https://www.google.com/accounts/ServiceLogin")
8
+
9
+ @http = TestHTTP.new
10
+ @http.extend Opticon::HTTP
11
+
12
+ @http.uri = @test_uri
13
+ end
14
+
15
+ def test_get
16
+ assert_kind_of Net::HTTPResponse, @http.get(@test_uri)
17
+ end
18
+
19
+ def test_response
20
+ assert_kind_of Net::HTTPResponse, @http.response
21
+ end
22
+
23
+ def test_response_reuse
24
+ response = @http.response
25
+
26
+ assert_equal response.object_id, @http.response.object_id
27
+
28
+ @http.uri = "http://www.google.ca"
29
+
30
+ response2 = @http.response
31
+ assert_not_equal response.object_id, @http.response.object_id
32
+ assert_equal response2.object_id, @http.response.object_id
33
+ end
34
+
35
+ def test_https_get
36
+ @http.uri = @test_https_uri
37
+ assert_kind_of Net::HTTPResponse, @http.response
38
+ assert_match "Sign in", @http.response.body
39
+ end
40
+
41
+ class TestHTTP
42
+ include Opticon::HTTP
43
+ attr_accessor :uri
44
+ end
45
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+ require 'net/http'
3
+ require 'opticon/failure'
4
+ require 'opticon/notifier'
5
+ require 'opticon/mailer'
6
+
7
+ class Opticon::HTTPTest < Test::Unit::TestCase
8
+
9
+ class DummyFailure < Opticon::Failure::Base
10
+ def failure_message
11
+ "This is a test!"
12
+ end
13
+ end
14
+
15
+ def setup
16
+ @failure = DummyFailure.new("http://nowhere.test/test", 200, nil)
17
+ end
18
+
19
+ def test_failure_notification
20
+ email = Opticon::Mailer.create_failure_notification(@failure, "test@test.ruby", "opticon@test.ruby")
21
+ assert_match(@failure.uri, email.subject)
22
+ assert_equal("test@test.ruby", email.to.first)
23
+ assert_match(@failure.uri, email.body)
24
+ assert_match(@failure.failure_message, email.body)
25
+ end
26
+ end
@@ -0,0 +1,77 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class Opticon::HTTPTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_response_code_tester
9
+ tester = Opticon::Tester::ResponseCodeTester.new
10
+ tester.uri = "http://www.yahoo.com"
11
+
12
+ assert tester.test(:success)
13
+ assert tester.test(200)
14
+ assert tester.test([200, 302])
15
+ assert !tester.test(:server_error)
16
+ end
17
+
18
+ def test_response_code_tester_failure
19
+ tester = Opticon::Tester::ResponseCodeTester.new
20
+ tester.uri = "http://www.yahoo.com/alskjdflaksjflkasjfklsTHIS_PAGE_DOESNT_EXIST"
21
+
22
+ assert tester.test(404)
23
+ assert !tester.test(:success)
24
+ assert_kind_of Opticon::Failure::ResponseCodeTestFailure, tester.failure
25
+ assert_equal 404.to_s, tester.failure.response.code.to_s
26
+ end
27
+
28
+ def test_response_code_tester_cant_connect
29
+ tester = Opticon::Tester::ResponseCodeTester.new
30
+ tester.uri = "http://there.is.no.such.server.foobarblah/test"
31
+
32
+ assert !tester.test(:success)
33
+ assert_kind_of Opticon::Failure::ConnectionFailure, tester.failure
34
+
35
+ tester = Opticon::Tester::ResponseCodeTester.new
36
+ tester.uri = "http://localhost:65489789"
37
+
38
+ assert !tester.test(:success)
39
+ assert_kind_of Opticon::Failure::ConnectionFailure, tester.failure
40
+ end
41
+
42
+ def test_content_tester_string
43
+ tester = Opticon::Tester::ContentTester.new
44
+
45
+ tester.uri = "http://code.google.com/p/opticon/"
46
+ assert tester.test("matt.zukowski"), tester.failure
47
+ assert_nil tester.failure
48
+
49
+ bad_string = "THIS STRING DOESNT EXIST IN OPTICON's GOOGLE CODE PAGE!!!"
50
+ assert !tester.test(bad_string), tester.failure
51
+ assert_equal bad_string, tester.failure.condition
52
+ end
53
+
54
+ def test_content_tester_regexp
55
+ tester = Opticon::Tester::ContentTester.new
56
+
57
+ tester.uri = "http://code.google.com/p/opticon/"
58
+ assert tester.test(/gnu general public license [23]\.[0-9]/i), tester.failure
59
+ assert_nil tester.failure
60
+
61
+ bad_regexp = /klasjfkljasdlkfjasklfjslkdfj/
62
+ assert !tester.test(bad_regexp), tester.failure
63
+ assert_equal bad_regexp, tester.failure.condition
64
+ end
65
+
66
+ def test_content_tester_fail_on_redirect
67
+ tester = Opticon::Tester::ContentTester.new
68
+
69
+ tester.uri = "http://google.com/"
70
+ # google will try to redirect to http://www.google.com/
71
+ assert_equal 302, tester.response.code.to_i
72
+ assert !tester.test("Google Search"), tester.failure
73
+ assert_equal "http://www.google.com/", tester.failure.response['location']
74
+ end
75
+
76
+
77
+ end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class OpticonTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/opticon'
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: opticon
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2007-02-20 00:00:00 -05:00
8
+ summary: Peace of mind through automated monitoring of your HTTP services.
9
+ require_paths:
10
+ - lib
11
+ email: matt [at] roughest.net
12
+ homepage: http://opticon.rubyforge.org
13
+ rubyforge_project: opticon
14
+ description: Peace of mind through automated monitoring of your HTTP services.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Matt Zukowski
31
+ files:
32
+ - Rakefile
33
+ - README.txt
34
+ - CHANGELOG.txt
35
+ - History.txt
36
+ - Manifest.txt
37
+ - examples/sample.rb
38
+ - lib/opticon.rb
39
+ - lib/opticon/failure.rb
40
+ - lib/opticon/http.rb
41
+ - lib/opticon/mailer.rb
42
+ - lib/opticon/mailer/failure_notification.rhtml
43
+ - lib/opticon/notifier.rb
44
+ - lib/opticon/runner.rb
45
+ - lib/opticon/service.rb
46
+ - lib/opticon/tester.rb
47
+ - lib/opticon/version.rb
48
+ - setup.rb
49
+ - test/opticon/http_test.rb
50
+ - test/opticon/mailer_test.rb
51
+ - test/opticon/tester_test.rb
52
+ - test/opticon_test.rb
53
+ - test/test_helper.rb
54
+ test_files:
55
+ - test/opticon_test.rb
56
+ - test/opticon/tester_test.rb
57
+ - test/opticon/mailer_test.rb
58
+ - test/opticon/http_test.rb
59
+ rdoc_options: []
60
+
61
+ extra_rdoc_files: []
62
+
63
+ executables: []
64
+
65
+ extensions: []
66
+
67
+ requirements: []
68
+
69
+ dependencies:
70
+ - !ruby/object:Gem::Dependency
71
+ name: actionmailer
72
+ version_requirement:
73
+ version_requirements: !ruby/object:Gem::Version::Requirement
74
+ requirements:
75
+ - - ">"
76
+ - !ruby/object:Gem::Version
77
+ version: 0.0.0
78
+ version: