Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 7
- Log:
Initial import of RForum 0.2 sources from a downloaded Tarball.
RForum is a Ruby On Rails based forum and mail gateway service.
- Author:
- adh
- Date:
- Sat Jul 22 18:43:13 +0100 2006
- Size:
- 2161 Bytes
1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | require File.dirname(__FILE__) + '/../../server/nntp' |
3 | |
4 | require 'test/unit' |
5 | require 'log4r' |
6 | |
7 | class NNTPTest < Test::Unit::TestCase |
8 | |
9 | def setup |
10 | create_fixtures 'posts', 'users', 'forums', 'topics' |
11 | |
12 | Thread.abort_on_exception = true |
13 | |
14 | logger = Log4r::Logger.new('nntpd') |
15 | logger.outputters = Log4r::Outputter.stdout |
16 | |
17 | @server = Thread.new do |
18 | NNTPSession.new(TCPServer.new('localhost', 9999).accept, logger).serve |
19 | end |
20 | |
21 | @client = TCPSocket.new('localhost', 9999) |
22 | assert_status 200, getline |
23 | end |
24 | |
25 | def teardown |
26 | putline 'QUIT' |
27 | assert_status 205, getline |
28 | end |
29 | |
30 | def getline |
31 | @client.gets("\r\n").chomp |
32 | end |
33 | |
34 | def getlongresp |
35 | s = @client.gets("\r\n.\r\n").sub(/\r\n\.\r\n$/, '') |
36 | end |
37 | |
38 | def putline(s) |
39 | @client.write(s.chomp + "\r\n") |
40 | end |
41 | |
42 | def test_server |
43 | # INVALID COMMAND |
44 | putline '(invalid command)' |
45 | assert_status 500, getline |
46 | |
47 | |
48 | # LIST |
49 | putline 'LIST' |
50 | # TODO |
51 | while getline != '.' |
52 | end |
53 | |
54 | # LIST OVERVIEW.FMT |
55 | putline 'LIST OVERVIEW.FMT' |
56 | s = getlongresp |
57 | assert_equal "Subject:\r\nFrom:\r\nDate:\r\nMessage-Id:\r\nReferences:\r\nBytes:\r\nLines:", s |
58 | |
59 | # GROUP |
60 | # |
61 | # existing group name |
62 | putline 'GROUP mikrocontroller.msp430' |
63 | assert_status 211, getline |
64 | |
65 | # invalid group name |
66 | putline 'GROUP invalid' |
67 | assert_status 411, getline |
68 | |
69 | |
70 | # AUTHINFO |
71 | # |
72 | # password without user name |
73 | putline 'AUTHINFO PASS foobar' |
74 | assert_status 482, getline |
75 | |
76 | # wrong password |
77 | putline 'AUTHINFO USER a' |
78 | assert_status 381, getline |
79 | putline 'AUTHINFO PASS wrong' |
80 | assert_status 502, getline |
81 | |
82 | # correct user & password |
83 | putline 'AUTHINFO USER a' |
84 | assert_status 381, getline |
85 | putline 'AUTHINFO PASS a' |
86 | assert_status 281, getline |
87 | |
88 | |
89 | putline 'NEWNEWS' |
90 | assert_status 502, getline |
91 | |
92 | |
93 | putline 'SLAVE' |
94 | assert_status 202, getline |
95 | |
96 | |
97 | putline 'MODE READER' |
98 | assert_status 200, getline |
99 | |
100 | |
101 | putline 'IHAVE' |
102 | assert_status 435, getline |
103 | end |
104 | |
105 | def assert_status status, line |
106 | assert_equal status, line.split[0].to_i |
107 | end |
108 | |
109 | end |