Git Product home page Git Product logo

zimsoap's Introduction

ZimSOAP : a programmatic python interface to zimbra

Build Status

ZimSOAP allows to access the SOAP Zimbra API through a programmatic, data-type-aware interface high-level. It also handle authentification, sessions, pre-authentication and delegated authentication.

Not all methods are covered, but you're welcome to wrap the ones you need and pull-request !

If you are looking at a lower-level lib, you better look to python-zimbra

Allows accessing zimbraAdmin and zimbraAccount SOAP APIs

  • handle authentification
  • handle pre-authentification admin->admin and admin->Account
  • presents the request results as nice Python objects
  • all requests are tested with 8.6.0

Installing

Simple:

pip install zimsoap

Or if you fetch it from git:

./setup.py install

API

API is accessible through the ZimbraAdminClient() method. Example :

zc = ZimbraAdminClient('myserver.example.tld')
zc.login('[email protected]', 'mypassword')

print("Domains on that zimbra instance :")
for domain in zc.get_all_domains():
    # Each domain is a zobject.Domain instance
    print('  - %s' % domain.name)

You can also access raw SOAP methods:

zc = ZimbraAdminClient()
zc.login('[email protected]', 'mypassword')
xml_response = self.zc.GetAllDomainsRequest()

If you want up-to-date code example, look at unit tests...

Testing

Most of tests are integration tests, they require a live zimbra server to be running.

The tests will assume some base data (provisioning scsripts included), create/update some, and cleanup after themselves. They may leave garbage data in case they crash.


DO NOT USE A PRODUCTION SERVER TO RUN TESTS.

Use a dedicated test server, unable to send emails over network and consider all Zimbra accounts/domains/settings are disposable for automated tests purposes.


Setting your environment for tests

Most of tests are Integration tests are to be run either :

  • against a pre-configured VM, using vagrant
  • using any zimbra server you provide, after reading the above warning.

Using the vagrant VM

There is a VM ready for you with vagrant, just make sure you have vagrant installed and then :

$ vagrant up 8.0.5
$ vagrant provision 8.0.5

You have several zimbra versions available as VMs for testing (see vagrant status).

Warning: the test VM requires 2GB RAM to function properly and may put heavy load on your machine.

Using your own zimbra server

Be sure to have a server:

  • running zimbra 8.x,
  • ports 7071 and 443 reachables
  • with an unix user having password-less sudo rights

First delete all accounts/domains/calendar resources from your test server and run :

cat tests/provision-01-test-data.zmprov | ssh user@mytestserver -- sudo su - zimbra -c | zmprov

(considering mytestserver is your server hostname and user is a unix user with admin sudo rights)

It will provision an admin account, but disabled. You have to set a password and enable the account

ssh user@mytestserver -- sudo su - zimbra -c 'zmprov sp [email protected] mypassword'
ssh user@mytestserver -- sudo su - zimbra -c 'zmprov ma [email protected] zimbraAccountStatus active'

Then create a test_config.ini in tests/ directory. Example content:

[zimbra_server]
host = mytestserver
server_name = zimbratest.example.com
admin_port = 7071
admin_login = [email protected]
admin_password = mypassword

note: server_name is the internal server name from your zimbra server list (generally matches the hostname)

If you damaged the data with failed tests, you can just delete everything except the admin account and then run :

cat tests/provision-01-test-data.zmprov | ssh user@mytestserver -- sudo su - zimbra -c | zmprov

Testing

After you are all set, you can run tests the standard python way

$ python -m unittest discover

โ€ฆ Or using py.test.

$ py.test

For contributing code, you may also want to run the flake8 linter:

$ pip install -r test-requirements.txt
$ make lint

zimsoap's People

Contributors

jocelyndelalande avatar tuxem avatar sylvainb avatar manens avatar yuntux avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.