summaryrefslogtreecommitdiffstats
path: root/tests/functional/test_wap_client/test_001_connect.py
blob: 783d996643684ec426d520a68a5e26eaabbf1736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import unittest

import pykolab
from pykolab import wap_client


class TestConnect(unittest.TestCase):
    @classmethod
    def setup_class(self, *args, **kw):
        conf = pykolab.getConf()
        conf.finalize_conf(fatal=False)

        self.login = conf.get('ldap', 'bind_dn')
        self.password = conf.get('ldap', 'bind_pw')
        self.domain = conf.get('kolab', 'primary_domain')

    def test_001_authenticate(self):
        result = wap_client.authenticate(self.login, self.password, self.domain)

    def test_002_response_ok(self):
        result = wap_client.request_raw('POST', 'domains.list')
        self.assertTrue('status' in result)
        self.assertTrue('result' in result)
        self.assertEqual(result['status'], "OK")

    def test_003_response_fail(self):
        result = wap_client.request_raw('POST', 'service.method')
        self.assertTrue('status' in result)
        self.assertTrue('reason' in result)
        self.assertTrue('code' in result)
        self.assertEqual(result['status'], "ERROR")
        self.assertEqual(result['reason'], "Unknown service")
        self.assertEqual(result['code'], 400)

    def test_004_domains_list(self):
        result = wap_client.domains_list()
        self.assertTrue('count' in result)
        self.assertTrue('list' in result)
        self.assertEqual(result['count'], len(result['list']))

    def test_005_get_domain(self):
        result = wap_client.request_raw('GET', 'system.get_domain')
        self.assertEqual(result, {u'status': u'OK', u'result': {u'domain': u'example.org'}})