Skip to content

Commit 98a124b

Browse files
committed
Added clean-method for request and response. Added administration-tests and new auth-tests.
1 parent 9bb630f commit 98a124b

19 files changed

+484
-52
lines changed

docs/.doctrees/environment.pickle

907 Bytes
Binary file not shown.

docs/.doctrees/pythonzimbra.doctree

2.83 KB
Binary file not shown.
68 Bytes
Binary file not shown.
33 Bytes
Binary file not shown.

docs/.doctrees/tests.doctree

9.38 KB
Binary file not shown.

docs/genindex.html

+36-2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ <h2 id="C">C</h2>
108108
<table style="width: 100%" class="indextable genindextable"><tr>
109109
<td style="width: 33%" valign="top"><dl>
110110

111+
<dt><a href="pythonzimbra.html#pythonzimbra.request.Request.clean">clean() (pythonzimbra.request.Request method)</a>
112+
</dt>
113+
114+
<dd><dl>
115+
116+
<dt><a href="pythonzimbra.html#pythonzimbra.response.Response.clean">(pythonzimbra.response.Response method)</a>
117+
</dt>
118+
119+
</dl></dd>
120+
111121
<dt><a href="tests.html#tests.test_request_json.TestRequestJson.cleanUp">cleanUp() (tests.test_request_json.TestRequestJson method)</a>
112122
</dt>
113123

@@ -406,6 +416,14 @@ <h2 id="T">T</h2>
406416

407417
</dl></dd>
408418

419+
<dt><a href="tests.html#tests.test_auth.TestAuth.test_admin_auth_json">test_admin_auth_json() (tests.test_auth.TestAuth method)</a>
420+
</dt>
421+
422+
423+
<dt><a href="tests.html#tests.test_auth.TestAuth.test_admin_auth_xml">test_admin_auth_xml() (tests.test_auth.TestAuth method)</a>
424+
</dt>
425+
426+
409427
<dt><a href="tests.html#tests.test_auth.TestAuth.test_auth_json">test_auth_json() (tests.test_auth.TestAuth method)</a>
410428
</dt>
411429

@@ -506,6 +524,10 @@ <h2 id="T">T</h2>
506524

507525
</dl></dd>
508526

527+
<dt><a href="tests.html#tests.test_response_xml.TestResponseXml.test_get_response_multi">test_get_response_multi() (tests.test_response_xml.TestResponseXml method)</a>
528+
</dt>
529+
530+
509531
<dt><a href="tests.html#tests.test_response_json.TestResponseJson.test_is_batch">test_is_batch() (tests.test_response_json.TestResponseJson method)</a>
510532
</dt>
511533

@@ -516,6 +538,16 @@ <h2 id="T">T</h2>
516538

517539
</dl></dd>
518540

541+
<dt><a href="tests.html#tests.test_auth.TestAuth.test_password_auth_json">test_password_auth_json() (tests.test_auth.TestAuth method)</a>
542+
</dt>
543+
544+
</dl></td>
545+
<td style="width: 33%" valign="top"><dl>
546+
547+
<dt><a href="tests.html#tests.test_auth.TestAuth.test_password_auth_xml">test_password_auth_xml() (tests.test_auth.TestAuth method)</a>
548+
</dt>
549+
550+
519551
<dt><a href="tests.html#tests.test_request_json.TestRequestJson.test_set_context_params">test_set_context_params() (tests.test_request_json.TestRequestJson method)</a>
520552
</dt>
521553

@@ -525,8 +557,6 @@ <h2 id="T">T</h2>
525557
</dt>
526558

527559
</dl></dd>
528-
</dl></td>
529-
<td style="width: 33%" valign="top"><dl>
530560

531561
<dt><a href="tests.html#tests.test_request_json.TestRequestJson.test_set_context_params_failtype">test_set_context_params_failtype() (tests.test_request_json.TestRequestJson method)</a>
532562
</dt>
@@ -552,6 +582,10 @@ <h2 id="T">T</h2>
552582

553583
</dl></dd>
554584

585+
<dt><a href="tests.html#tests.test_response_xml.TestResponseXml.tested_server_result_multi_value">tested_server_result_multi_value (tests.test_response_xml.TestResponseXml attribute)</a>
586+
</dt>
587+
588+
555589
<dt><a href="tests.html#tests.test_preauth.TestPreauth">TestPreauth (class in tests.test_preauth)</a>
556590
</dt>
557591

docs/objects.inv

55 Bytes
Binary file not shown.

docs/pythonzimbra.html

+12
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ <h2><a class="reference internal" href="#module-pythonzimbra" title="pythonzimbr
165165
<dd><p>If so, keep the current request id</p>
166166
</dd></dl>
167167

168+
<dl class="method">
169+
<dt id="pythonzimbra.request.Request.clean">
170+
<tt class="descname">clean</tt><big>(</big><big>)</big><a class="headerlink" href="#pythonzimbra.request.Request.clean" title="Permalink to this definition"></a></dt>
171+
<dd><p>Clean up request, so the request object can be reused</p>
172+
</dd></dl>
173+
168174
<dl class="method">
169175
<dt id="pythonzimbra.request.Request.enable_batch">
170176
<tt class="descname">enable_batch</tt><big>(</big><em>namespace</em>, <em>onerror='continue'</em><big>)</big><a class="reference internal" href="_modules/pythonzimbra/request.html#Request.enable_batch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pythonzimbra.request.Request.enable_batch" title="Permalink to this definition"></a></dt>
@@ -276,6 +282,12 @@ <h2><a class="reference internal" href="#module-pythonzimbra" title="pythonzimbr
276282
<em class="property">class </em><tt class="descclassname">pythonzimbra.response.</tt><tt class="descname">Response</tt><a class="reference internal" href="_modules/pythonzimbra/response.html#Response"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pythonzimbra.response.Response" title="Permalink to this definition"></a></dt>
277283
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
278284
<p>Unified access to Zimbra responses.</p>
285+
<dl class="method">
286+
<dt id="pythonzimbra.response.Response.clean">
287+
<tt class="descname">clean</tt><big>(</big><big>)</big><a class="headerlink" href="#pythonzimbra.response.Response.clean" title="Permalink to this definition"></a></dt>
288+
<dd><p>Clean up the response, so it can be used again</p>
289+
</dd></dl>
290+
279291
<dl class="method">
280292
<dt id="pythonzimbra.response.Response.get_batch">
281293
<tt class="descname">get_batch</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pythonzimbra/response.html#Response.get_batch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pythonzimbra.response.Response.get_batch" title="Permalink to this definition"></a></dt>

docs/searchindex.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/tests.html

+42
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,20 @@ <h2><a class="reference internal" href="#module-tests" title="tests"><tt class="
6868
<dt id="tests.test_auth.TestAuth">
6969
<em class="property">class </em><tt class="descclassname">tests.test_auth.</tt><tt class="descname">TestAuth</tt><big>(</big><em>methodName='runTest'</em><big>)</big><a class="reference internal" href="_modules/tests/test_auth.html#TestAuth"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#tests.test_auth.TestAuth" title="Permalink to this definition"></a></dt>
7070
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">unittest.case.TestCase</span></tt></p>
71+
<dl class="method">
72+
<dt id="tests.test_auth.TestAuth.test_admin_auth_json">
73+
<tt class="descname">test_admin_auth_json</tt><big>(</big><big>)</big><a class="headerlink" href="#tests.test_auth.TestAuth.test_admin_auth_json" title="Permalink to this definition"></a></dt>
74+
<dd><p>Send a configured admin auth request in json format using the
75+
admin auth-method and check a successfully returned token</p>
76+
</dd></dl>
77+
78+
<dl class="method">
79+
<dt id="tests.test_auth.TestAuth.test_admin_auth_xml">
80+
<tt class="descname">test_admin_auth_xml</tt><big>(</big><big>)</big><a class="headerlink" href="#tests.test_auth.TestAuth.test_admin_auth_xml" title="Permalink to this definition"></a></dt>
81+
<dd><p>Send a configured admin auth request in xml format using the
82+
admin auth-method and check a successfully returned token</p>
83+
</dd></dl>
84+
7185
<dl class="method">
7286
<dt id="tests.test_auth.TestAuth.test_auth_json">
7387
<tt class="descname">test_auth_json</tt><big>(</big><big>)</big><a class="headerlink" href="#tests.test_auth.TestAuth.test_auth_json" title="Permalink to this definition"></a></dt>
@@ -82,6 +96,20 @@ <h2><a class="reference internal" href="#module-tests" title="tests"><tt class="
8296
successfully returned token</p>
8397
</dd></dl>
8498

99+
<dl class="method">
100+
<dt id="tests.test_auth.TestAuth.test_password_auth_json">
101+
<tt class="descname">test_password_auth_json</tt><big>(</big><big>)</big><a class="headerlink" href="#tests.test_auth.TestAuth.test_password_auth_json" title="Permalink to this definition"></a></dt>
102+
<dd><p>Send a configured auth request in json format using password
103+
based authentication and check a successfully returned token</p>
104+
</dd></dl>
105+
106+
<dl class="method">
107+
<dt id="tests.test_auth.TestAuth.test_password_auth_xml">
108+
<tt class="descname">test_password_auth_xml</tt><big>(</big><big>)</big><a class="headerlink" href="#tests.test_auth.TestAuth.test_password_auth_xml" title="Permalink to this definition"></a></dt>
109+
<dd><p>Send a configured auth request in xml format using password
110+
based authentication and check a successfully returned token</p>
111+
</dd></dl>
112+
85113
</dd></dl>
86114

87115
</div>
@@ -366,6 +394,14 @@ <h2><a class="reference internal" href="#module-tests" title="tests"><tt class="
366394
<tt class="descname">test_get_response</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/tests/test_response_xml.html#TestResponseXml.test_get_response"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#tests.test_response_xml.TestResponseXml.test_get_response" title="Permalink to this definition"></a></dt>
367395
<dd></dd></dl>
368396

397+
<dl class="method">
398+
<dt id="tests.test_response_xml.TestResponseXml.test_get_response_multi">
399+
<tt class="descname">test_get_response_multi</tt><big>(</big><big>)</big><a class="headerlink" href="#tests.test_response_xml.TestResponseXml.test_get_response_multi" title="Permalink to this definition"></a></dt>
400+
<dd><p>For cases where we have several tags with the same name.</p>
401+
<p>In that case, for a given tag name as a key, we want a list of dicts
402+
containing the content of each tag, instead of a single dict.</p>
403+
</dd></dl>
404+
369405
<dl class="method">
370406
<dt id="tests.test_response_xml.TestResponseXml.test_is_batch">
371407
<tt class="descname">test_is_batch</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/tests/test_response_xml.html#TestResponseXml.test_is_batch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#tests.test_response_xml.TestResponseXml.test_is_batch" title="Permalink to this definition"></a></dt>
@@ -378,6 +414,12 @@ <h2><a class="reference internal" href="#module-tests" title="tests"><tt class="
378414
running zmsoap -z &#8211;json -t admin GetVersionInfoRequest -vv)</p>
379415
</dd></dl>
380416

417+
<dl class="attribute">
418+
<dt id="tests.test_response_xml.TestResponseXml.tested_server_result_multi_value">
419+
<tt class="descname">tested_server_result_multi_value</tt><em class="property"> = '&lt;soap:Envelope xmlns:soap=&quot;http://www.w3.org/2003/05/soap-envelope&quot;&gt;&lt;soap:Header&gt;&lt;context xmlns=&quot;urn:zimbra&quot;/&gt;&lt;/soap:Header&gt;&lt;soap:Body&gt;&lt;GetAllDomainsResponse&gt; &lt;domain id=&quot;b37d6b9&quot; name=&quot;client1.unbound.example.fr&quot;&gt;&lt;/domain&gt;&lt;domain id=&quot;444d6b9&quot; name=&quot;client1.unbound.example.fr&quot;&gt;&lt;/domain&gt;&lt;/GetAllDomainsResponse&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;'</em><a class="headerlink" href="#tests.test_response_xml.TestResponseXml.tested_server_result_multi_value" title="Permalink to this definition"></a></dt>
420+
<dd><p>This one is a stripped version of a GetAlDomains</p>
421+
</dd></dl>
422+
381423
</dd></dl>
382424

383425
</div>

pythonzimbra/request.py

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ class Request(object):
2323

2424
""" If so, keep the current request id """
2525

26+
def clean(self):
27+
28+
""" Clean up request, so the request object can be reused
29+
"""
30+
31+
self.batch_request = False
32+
self.batch_request_id = None
33+
2634
def set_context_params(self, params):
2735

2836
""" Set header context parameters. Refer to the top of <Zimbra

pythonzimbra/request_json.py

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def __init__(self):
2727
'Body': {}
2828
}
2929

30+
def clean(self):
31+
super(RequestJson, self).clean()
32+
33+
self.__init__()
34+
3035
def set_context_params(self, params):
3136

3237
# Call parent method

pythonzimbra/request_xml.py

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ def __init__(self):
5757

5858
self.request_doc.appendChild(root_node)
5959

60+
def clean(self):
61+
super(RequestXml, self).clean()
62+
63+
self.__init__()
64+
6065
def set_context_params(self, params):
6166

6267
# Call parent method

pythonzimbra/response.py

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ class Response(object):
77
88
"""
99

10+
def clean(self):
11+
12+
""" Clean up the response, so it can be used again
13+
"""
14+
15+
pass
16+
1017
def set_response(self, response_text):
1118

1219
""" Interpret the response object.

pythonzimbra/response_json.py

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ class ResponseJson(Response):
1010

1111
""" The dictionary we'll be working on """
1212

13+
def clean(self):
14+
super(ResponseJson, self).clean()
15+
self.response_dict = None
16+
1317
def set_response(self, response_text):
1418

1519
self.response_dict = json.loads(response_text)

pythonzimbra/response_xml.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ class ResponseXml(Response):
1111

1212
""" The response document we're working on """
1313

14+
def clean(self):
15+
super(ResponseXml, self).clean()
16+
self.response_doc = None
17+
1418
def set_response(self, response_text):
1519

1620
self.response_doc = minidom.parseString(response_text)

tests/config.ini.dist

+71
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Additional configuration for tests
22

3+
# Testing user authentication using preauth key
4+
35
[auth_test]
46

57
# The URL of the zimbra soap service
@@ -23,3 +25,72 @@ timestamp=None
2325
# Is the auth testing enabled? Set this to true if you have configured the
2426
# other values!
2527
enabled=False
28+
29+
# Testing user authentication using password
30+
31+
[auth_by_password_test]
32+
33+
# The URL of the zimbra soap service
34+
url=None
35+
36+
# The account to be logged in using password based authentication
37+
account=None
38+
39+
# The password of the account
40+
password=None
41+
42+
# What is in "account"? A name, an ID, a ForeignPrincipal?
43+
account_by=name
44+
45+
# Is the auth testing enabled? Set this to true if you have configured the
46+
# other values!
47+
enabled=False
48+
49+
# Testing admin authentication (using password)
50+
51+
[admin_auth_test]
52+
53+
# The URL of the zimbra admin-soap service
54+
url=None
55+
56+
# The admin account to be logged in
57+
account=None
58+
59+
# The password of the admin account
60+
password=None
61+
62+
# What is in "account"? A name, an ID, a ForeignPrincipal?
63+
account_by=name
64+
65+
# Is the auth testing enabled? Set this to true if you have configured the
66+
# other values!
67+
enabled=False
68+
69+
# Testing creating and removing an account
70+
71+
[admin_request_test]
72+
73+
# The URL of the zimbra admin-soap service
74+
url=None
75+
76+
# The admin account to be logged in
77+
account=None
78+
79+
# The password of the admin account
80+
password=None
81+
82+
# What is in "account"? A name, an ID, a ForeignPrincipal?
83+
account_by=name
84+
85+
# What URL to use for testing the authentication of the new user
86+
user_url=None
87+
88+
# What account can be created and removed for testing purposes?
89+
test_account=None
90+
91+
# The password of that account
92+
test_password=None
93+
94+
# Is the auth testing enabled? Set this to true if you have configured the
95+
# other values!
96+
enabled=False

0 commit comments

Comments
 (0)