Beispiel #1
0
class UsernameDigestTokenTests(unittest.TestCase):

    def setUp(self):
        self.token = UsernameDigestToken('myself', 'mypassword')

    def tearDown(self):
        self.token = None

    def test_simple(self):
        self.assertIsInstance(self.token, UsernameDigestToken)
        xml = self.token.xml()
        self.assertIsInstance(xml, Element)
        self.assertIsInstance(xml.getChild('Username', ns=wssens), Element)
        self.assertIsInstance(xml.getChild('Password', ns=wssens), Element)
        self.assertIsInstance(xml.getChild('Nonce', ns=wssens), Element)

    def test_set_custom_nonce(self):
        self.assertIsInstance(self.token, UsernameDigestToken)
        self.token.setnonce('NONCE'.encode('utf-8'))
        xml = self.token.xml()
        self.assertIsInstance(xml, Element)
        self.assertIsInstance(xml.getChild('Username', ns=wssens), Element)
        self.assertIsInstance(xml.getChild('Password', ns=wssens), Element)
        self.assertIsInstance(xml.getChild('Nonce', ns=wssens), Element)
        self.assertEquals(
            xml.getChild('Nonce', ns=wssens).getText(),
            b64encode('NONCE'.encode('utf-8')).decode('utf-8')
        )
Beispiel #2
0
class UsernameDigestTokenTests(unittest.TestCase):
    def setUp(self):
        self.token = UsernameDigestToken('myself', 'mypassword')

    def tearDown(self):
        self.token = None

    def test_simple(self):
        self.assertIsInstance(self.token, UsernameDigestToken)
        xml = self.token.xml()
        self.assertIsInstance(xml, Element)
        self.assertIsInstance(xml.getChild('Username', ns=wssens), Element)
        self.assertIsInstance(xml.getChild('Password', ns=wssens), Element)
        self.assertIsInstance(xml.getChild('Nonce', ns=wssens), Element)

    def test_set_custom_nonce(self):
        self.assertIsInstance(self.token, UsernameDigestToken)
        self.token.setnonce('NONCE'.encode('utf-8'))
        xml = self.token.xml()
        self.assertIsInstance(xml, Element)
        self.assertIsInstance(xml.getChild('Username', ns=wssens), Element)
        self.assertIsInstance(xml.getChild('Password', ns=wssens), Element)
        self.assertIsInstance(xml.getChild('Nonce', ns=wssens), Element)
        self.assertEquals(
            xml.getChild('Nonce', ns=wssens).getText(),
            b64encode('NONCE'.encode('utf-8')).decode('utf-8'))
Beispiel #3
0
def capakey_request(client, action, *args):
    '''
    Utility function that helps making requests to the CAPAKEY service.

    :param client: A :class:`suds.client.Client` for the CAPAKEY service.
    :param string action: Which method to call, eg. `ListAdmGemeenten`.
    :returns: Result of the SOAP call.
    '''
    security = Security()
    token = UsernameDigestToken(client.capakey_user, client.capakey_password)
    security.tokens.append(token)
    client.set_options(wsse=security)

    cm = getattr(client.service, action)
    a = Action(cm.method.soap.action)
    mid = MessageID()
    t = To(cm.method.location)
    client.set_options(soapheaders=[a.xml(), t.xml(), mid.xml()])

    log.debug('Calling %s on CAPAKEY service.', action)
    return getattr(client.service, action)(*args)
Beispiel #4
0
 def setUp(self):
     self.token = UsernameDigestToken('myself', 'mypassword')
Beispiel #5
0
 def setUp(self):
     self.token = UsernameDigestToken('myself', 'mypassword')