Exemple #1
0
class HTTPAuthRealmTestCase(TestCase):

    def setUp(self):
        self.realm = HTTPAuthRealm("a resource")

    def test_creation(self):
        self.assertEquals(self.realm.resource, "a resource")

    def test_requestAvatarWeb(self):
        from twisted.web.resource import IResource
        interface, resource, logoutMethod = self.realm.requestAvatar(
            "an id", None, IResource)
        self.assertEquals(interface, IResource)
        self.assertEquals(resource, self.realm.resource)
        self.assertEquals(logoutMethod, self.realm.logout)

    def test_requestAvatarWeb2(self):
        from twisted.web2.iweb import IResource
        interface, resource = self.realm.requestAvatar(
            "an id", None, IResource)
        self.assertEquals(interface, IResource)
        self.assertEquals(resource, self.realm.resource)

    def test_requestAvatarNonWeb(self):
        self.assertRaises(NotImplementedError, self.realm.requestAvatar,
                          "an id", None, [Interface])
Exemple #2
0
class HTTPAuthRealmTestCase(TestCase):

    RESOURCE_NAME = 'Test Auth resource'

    def setUp(self):
        self.realm = HTTPAuthRealm(self.RESOURCE_NAME)

    def test_creation(self):
        self.assertEquals(self.realm.resource, self.RESOURCE_NAME)

    def test_logout(self):
        """Logout of the realm causes no errors."""
        # This isn't a great test, but it executes the code.
        self.assertEquals(None, self.realm.logout())

    def test_requestAvatarWeb(self):
        from twisted.web.resource import IResource
        interface, resource, logoutMethod = self.realm.requestAvatar(
            "an id", None, IResource)
        self.assertEquals(interface, IResource)
        self.assertEquals(resource, self.realm.resource)
        self.assertEquals(logoutMethod, self.realm.logout)

    def test_requestAvatarNonWeb(self):
        self.assertRaises(NotImplementedError, self.realm.requestAvatar,
                          "an id", None, [Interface])
class HTTPAuthRealmTestCase(TestCase):

    RESOURCE_NAME = 'Test Auth resource'

    def setUp(self):
        self.realm = HTTPAuthRealm(self.RESOURCE_NAME)

    def test_creation(self):
        self.assertEquals(self.realm.resource, self.RESOURCE_NAME)

    def test_logout(self):
        """Logout of the realm causes no errors."""
        # This isn't a great test, but it executes the code.
        self.assertEquals(None, self.realm.logout())

    def test_requestAvatarWeb(self):
        from twisted.web.resource import IResource
        interface, resource, logoutMethod = self.realm.requestAvatar(
            "an id", None, IResource)
        self.assertEquals(interface, IResource)
        self.assertEquals(resource, self.realm.resource)
        self.assertEquals(logoutMethod, self.realm.logout)

    def test_requestAvatarNonWeb(self):
        self.assertRaises(NotImplementedError, self.realm.requestAvatar,
                          "an id", None, [Interface])
Exemple #4
0
class HTTPAuthRealmTestCase(TestCase):
    def setUp(self):
        self.realm = HTTPAuthRealm("a resource")

    def test_creation(self):
        self.assertEquals(self.realm.resource, "a resource")

    def test_requestAvatarWeb(self):
        from twisted.web.resource import IResource
        interface, resource, logoutMethod = self.realm.requestAvatar(
            "an id", None, IResource)
        self.assertEquals(interface, IResource)
        self.assertEquals(resource, self.realm.resource)
        self.assertEquals(logoutMethod, self.realm.logout)

    def test_requestAvatarNonWeb(self):
        self.assertRaises(NotImplementedError, self.realm.requestAvatar,
                          "an id", None, [Interface])