1
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
1
# Copyright (c) 2001-2009 Twisted Matrix Laboratories.
2
2
# See LICENSE for details.
5
Tests for L{twisted.protocols.finger}.
5
8
from twisted.trial import unittest
6
9
from twisted.protocols import finger
7
from twisted.internet import reactor, protocol
8
from twisted.test import test_protocols
10
from twisted.test.proto_helpers import StringTransport
10
13
class FingerTestCase(unittest.TestCase):
15
Tests for L{finger.Finger}.
13
self.t = test_protocols.StringIOWithoutClosing()
14
self.p = finger.Finger()
15
self.p.makeConnection(protocol.FileWrapper(self.t))
18
self.p.dataReceived("moshez\r\n")
19
self.failUnlessEqual(self.t.getvalue(),
20
"Login: moshez\nNo such user\n")
22
def testSimpleW(self):
23
self.p.dataReceived("/w moshez\r\n")
24
self.failUnlessEqual(self.t.getvalue(),
25
"Login: moshez\nNo such user\n")
27
def testForwarding(self):
28
self.p.dataReceived("moshez@example.com\r\n")
29
self.failUnlessEqual(self.t.getvalue(),
30
"Finger forwarding service denied\n")
33
self.p.dataReceived("\r\n")
34
self.failUnlessEqual(self.t.getvalue(),
35
"Finger online list denied\n")
19
Create and connect a L{finger.Finger} instance.
21
self.transport = StringTransport()
22
self.protocol = finger.Finger()
23
self.protocol.makeConnection(self.transport)
26
def test_simple(self):
28
When L{finger.Finger} receives a CR LF terminated line, it responds
29
with the default user status message - that no such user exists.
31
self.protocol.dataReceived("moshez\r\n")
33
self.transport.value(),
34
"Login: moshez\nNo such user\n")
37
def test_simpleW(self):
39
The behavior for a query which begins with C{"/w"} is the same as the
40
behavior for one which does not. The user is reported as not existing.
42
self.protocol.dataReceived("/w moshez\r\n")
44
self.transport.value(),
45
"Login: moshez\nNo such user\n")
48
def test_forwarding(self):
50
When L{finger.Finger} receives a request for a remote user, it responds
51
with a message rejecting the request.
53
self.protocol.dataReceived("moshez@example.com\r\n")
55
self.transport.value(),
56
"Finger forwarding service denied\n")
61
When L{finger.Finger} receives a blank line, it responds with a message
62
rejecting the request for all online users.
64
self.protocol.dataReceived("\r\n")
66
self.transport.value(),
67
"Finger online list denied\n")