Skip to content

Commit

Permalink
Added clean-method for request and response. Added administration-tes…
Browse files Browse the repository at this point in the history
…ts and new auth-tests.
  • Loading branch information
dploeger committed Jan 9, 2014
1 parent 9bb630f commit 98a124b
Show file tree
Hide file tree
Showing 19 changed files with 484 additions and 52 deletions.
Binary file modified docs/.doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/.doctrees/pythonzimbra.doctree
Binary file not shown.
Binary file modified docs/.doctrees/pythonzimbra.exceptions.doctree
Binary file not shown.
Binary file modified docs/.doctrees/pythonzimbra.tools.doctree
Binary file not shown.
Binary file modified docs/.doctrees/tests.doctree
Binary file not shown.
38 changes: 36 additions & 2 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ <h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>

<dt><a href="pythonzimbra.html#pythonzimbra.request.Request.clean">clean() (pythonzimbra.request.Request method)</a>
</dt>

<dd><dl>

<dt><a href="pythonzimbra.html#pythonzimbra.response.Response.clean">(pythonzimbra.response.Response method)</a>
</dt>

</dl></dd>

<dt><a href="tests.html#tests.test_request_json.TestRequestJson.cleanUp">cleanUp() (tests.test_request_json.TestRequestJson method)</a>
</dt>

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

</dl></dd>

<dt><a href="tests.html#tests.test_auth.TestAuth.test_admin_auth_json">test_admin_auth_json() (tests.test_auth.TestAuth method)</a>
</dt>


<dt><a href="tests.html#tests.test_auth.TestAuth.test_admin_auth_xml">test_admin_auth_xml() (tests.test_auth.TestAuth method)</a>
</dt>


<dt><a href="tests.html#tests.test_auth.TestAuth.test_auth_json">test_auth_json() (tests.test_auth.TestAuth method)</a>
</dt>

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

</dl></dd>

<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>
</dt>


<dt><a href="tests.html#tests.test_response_json.TestResponseJson.test_is_batch">test_is_batch() (tests.test_response_json.TestResponseJson method)</a>
</dt>

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

</dl></dd>

<dt><a href="tests.html#tests.test_auth.TestAuth.test_password_auth_json">test_password_auth_json() (tests.test_auth.TestAuth method)</a>
</dt>

</dl></td>
<td style="width: 33%" valign="top"><dl>

<dt><a href="tests.html#tests.test_auth.TestAuth.test_password_auth_xml">test_password_auth_xml() (tests.test_auth.TestAuth method)</a>
</dt>


<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>
</dt>

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

</dl></dd>
</dl></td>
<td style="width: 33%" valign="top"><dl>

<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>
</dt>
Expand All @@ -552,6 +582,10 @@ <h2 id="T">T</h2>

</dl></dd>

<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>
</dt>


<dt><a href="tests.html#tests.test_preauth.TestPreauth">TestPreauth (class in tests.test_preauth)</a>
</dt>

Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
12 changes: 12 additions & 0 deletions docs/pythonzimbra.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ <h2><a class="reference internal" href="#module-pythonzimbra" title="pythonzimbr
<dd><p>If so, keep the current request id</p>
</dd></dl>

<dl class="method">
<dt id="pythonzimbra.request.Request.clean">
<tt class="descname">clean</tt><big>(</big><big>)</big><a class="headerlink" href="#pythonzimbra.request.Request.clean" title="Permalink to this definition"></a></dt>
<dd><p>Clean up request, so the request object can be reused</p>
</dd></dl>

<dl class="method">
<dt id="pythonzimbra.request.Request.enable_batch">
<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>
Expand Down Expand Up @@ -276,6 +282,12 @@ <h2><a class="reference internal" href="#module-pythonzimbra" title="pythonzimbr
<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>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Unified access to Zimbra responses.</p>
<dl class="method">
<dt id="pythonzimbra.response.Response.clean">
<tt class="descname">clean</tt><big>(</big><big>)</big><a class="headerlink" href="#pythonzimbra.response.Response.clean" title="Permalink to this definition"></a></dt>
<dd><p>Clean up the response, so it can be used again</p>
</dd></dl>

<dl class="method">
<dt id="pythonzimbra.response.Response.get_batch">
<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>
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions docs/tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ <h2><a class="reference internal" href="#module-tests" title="tests"><tt class="
<dt id="tests.test_auth.TestAuth">
<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>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">unittest.case.TestCase</span></tt></p>
<dl class="method">
<dt id="tests.test_auth.TestAuth.test_admin_auth_json">
<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>
<dd><p>Send a configured admin auth request in json format using the
admin auth-method and check a successfully returned token</p>
</dd></dl>

<dl class="method">
<dt id="tests.test_auth.TestAuth.test_admin_auth_xml">
<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>
<dd><p>Send a configured admin auth request in xml format using the
admin auth-method and check a successfully returned token</p>
</dd></dl>

<dl class="method">
<dt id="tests.test_auth.TestAuth.test_auth_json">
<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>
Expand All @@ -82,6 +96,20 @@ <h2><a class="reference internal" href="#module-tests" title="tests"><tt class="
successfully returned token</p>
</dd></dl>

<dl class="method">
<dt id="tests.test_auth.TestAuth.test_password_auth_json">
<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>
<dd><p>Send a configured auth request in json format using password
based authentication and check a successfully returned token</p>
</dd></dl>

<dl class="method">
<dt id="tests.test_auth.TestAuth.test_password_auth_xml">
<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>
<dd><p>Send a configured auth request in xml format using password
based authentication and check a successfully returned token</p>
</dd></dl>

</dd></dl>

</div>
Expand Down Expand Up @@ -366,6 +394,14 @@ <h2><a class="reference internal" href="#module-tests" title="tests"><tt class="
<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>
<dd></dd></dl>

<dl class="method">
<dt id="tests.test_response_xml.TestResponseXml.test_get_response_multi">
<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>
<dd><p>For cases where we have several tags with the same name.</p>
<p>In that case, for a given tag name as a key, we want a list of dicts
containing the content of each tag, instead of a single dict.</p>
</dd></dl>

<dl class="method">
<dt id="tests.test_response_xml.TestResponseXml.test_is_batch">
<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>
Expand All @@ -378,6 +414,12 @@ <h2><a class="reference internal" href="#module-tests" title="tests"><tt class="
running zmsoap -z &#8211;json -t admin GetVersionInfoRequest -vv)</p>
</dd></dl>

<dl class="attribute">
<dt id="tests.test_response_xml.TestResponseXml.tested_server_result_multi_value">
<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>
<dd><p>This one is a stripped version of a GetAlDomains</p>
</dd></dl>

</dd></dl>

</div>
Expand Down
8 changes: 8 additions & 0 deletions pythonzimbra/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ class Request(object):

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

def clean(self):

""" Clean up request, so the request object can be reused
"""

self.batch_request = False
self.batch_request_id = None

def set_context_params(self, params):

""" Set header context parameters. Refer to the top of <Zimbra
Expand Down
5 changes: 5 additions & 0 deletions pythonzimbra/request_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ def __init__(self):
'Body': {}
}

def clean(self):
super(RequestJson, self).clean()

self.__init__()

def set_context_params(self, params):

# Call parent method
Expand Down
5 changes: 5 additions & 0 deletions pythonzimbra/request_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def __init__(self):

self.request_doc.appendChild(root_node)

def clean(self):
super(RequestXml, self).clean()

self.__init__()

def set_context_params(self, params):

# Call parent method
Expand Down
7 changes: 7 additions & 0 deletions pythonzimbra/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ class Response(object):
"""

def clean(self):

""" Clean up the response, so it can be used again
"""

pass

def set_response(self, response_text):

""" Interpret the response object.
Expand Down
4 changes: 4 additions & 0 deletions pythonzimbra/response_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class ResponseJson(Response):

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

def clean(self):
super(ResponseJson, self).clean()
self.response_dict = None

def set_response(self, response_text):

self.response_dict = json.loads(response_text)
Expand Down
4 changes: 4 additions & 0 deletions pythonzimbra/response_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class ResponseXml(Response):

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

def clean(self):
super(ResponseXml, self).clean()
self.response_doc = None

def set_response(self, response_text):

self.response_doc = minidom.parseString(response_text)
Expand Down
71 changes: 71 additions & 0 deletions tests/config.ini.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Additional configuration for tests

# Testing user authentication using preauth key

[auth_test]

# The URL of the zimbra soap service
Expand All @@ -23,3 +25,72 @@ timestamp=None
# Is the auth testing enabled? Set this to true if you have configured the
# other values!
enabled=False

# Testing user authentication using password

[auth_by_password_test]

# The URL of the zimbra soap service
url=None

# The account to be logged in using password based authentication
account=None

# The password of the account
password=None

# What is in "account"? A name, an ID, a ForeignPrincipal?
account_by=name

# Is the auth testing enabled? Set this to true if you have configured the
# other values!
enabled=False

# Testing admin authentication (using password)

[admin_auth_test]

# The URL of the zimbra admin-soap service
url=None

# The admin account to be logged in
account=None

# The password of the admin account
password=None

# What is in "account"? A name, an ID, a ForeignPrincipal?
account_by=name

# Is the auth testing enabled? Set this to true if you have configured the
# other values!
enabled=False

# Testing creating and removing an account

[admin_request_test]

# The URL of the zimbra admin-soap service
url=None

# The admin account to be logged in
account=None

# The password of the admin account
password=None

# What is in "account"? A name, an ID, a ForeignPrincipal?
account_by=name

# What URL to use for testing the authentication of the new user
user_url=None

# What account can be created and removed for testing purposes?
test_account=None

# The password of that account
test_password=None

# Is the auth testing enabled? Set this to true if you have configured the
# other values!
enabled=False
Loading

0 comments on commit 98a124b

Please sign in to comment.