Skip to content

Commit

Permalink
misuse git some more, maybe - here's where the unit tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
exarkun committed Dec 9, 2010
1 parent e1174d9 commit ed5ee53
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions master/buildbot/test/unit/test_changes_pb.py
Expand Up @@ -6,8 +6,9 @@
from twisted.trial.unittest import TestCase
from twisted.spread.pb import IPerspective
from twisted.cred.credentials import UsernamePassword
from twisted.python.filepath import FilePath

from buildbot.master import BotMaster
from buildbot.master import BuildMaster
from buildbot.changes.pb import ChangePerspective, PBChangeSource

class TestPBChangeSource(TestCase):
Expand All @@ -16,35 +17,46 @@ class TestPBChangeSource(TestCase):
"""
def setUp(self):
"""
Create an unstarted BotMaster instance with a PBChangeSource as a child.
Create an unstarted BuildMaster instance with a PBChangeSource as a
child.
"""
self.username = 'alice'
self.password = 'sekret'
self.master = BotMaster()
path = FilePath(self.mktemp())
path.makedirs()
self.master = BuildMaster(path.path)
self.master.readConfig = True # XXX OPPOSITE DAY
self.change_source = PBChangeSource(self.username, self.password)
self.master.change_svc.addSource(self.change_source)


def test_authentication(self):
"""
After the BotMaster service starts, the PBChangeSource's credentials are
accepted by the master's credentials checker.
After the BuildMaster service starts, the PBChangeSource's credentials
are accepted by the master's credentials checker.
"""
self.master.startService()
self.assertEquals(
self.master.checker.requestAvatarId(
UsernamePassword(self.username, self.password)),
self.username)
d = self.master.checker.requestAvatarId(
UsernamePassword(self.username, self.password))
def checkUsername(result):
self.assertEquals(result, self.username)
d.addCallback(checkUsername)
return d


def test_authorization(self):
"""
After the BotMaster service starts, a ChangePerspective can be retrieved
from the master's dispatcher (realm) with the PBChangeSource's username
(avatar identifier).
After the BuildMaster service starts, a ChangePerspective can be
retrieved from the master's dispatcher (realm) with the PBChangeSource's
username (avatar identifier).
"""
self.master.startService()
perspective = self.master.dispatcher.requestAvatar(
d = self.master.dispatcher.requestAvatar(
self.username, None, IPerspective)
self.assertIsInstance(perspective, ChangePerspective)
def checkLogin((interface, avatar, logout)):
self.assertIdentical(interface, IPerspective)
self.assertIsInstance(avatar, ChangePerspective)
d.addCallback(checkLogin)
return d


0 comments on commit ed5ee53

Please sign in to comment.