Statistics
| Branch: | Tag: | Revision:

root / snf-tools / synnefo_tools / burnin / astakos_tests.py @ 9355a604

History | View | Annotate | Download (2.9 kB)

1 4c52d5bf Ilias Tsitsimpis
# Copyright 2013 GRNET S.A. All rights reserved.
2 4c52d5bf Ilias Tsitsimpis
#
3 4c52d5bf Ilias Tsitsimpis
# Redistribution and use in source and binary forms, with or
4 4c52d5bf Ilias Tsitsimpis
# without modification, are permitted provided that the following
5 4c52d5bf Ilias Tsitsimpis
# conditions are met:
6 4c52d5bf Ilias Tsitsimpis
#
7 4c52d5bf Ilias Tsitsimpis
#   1. Redistributions of source code must retain the above
8 4c52d5bf Ilias Tsitsimpis
#      copyright notice, this list of conditions and the following
9 4c52d5bf Ilias Tsitsimpis
#      disclaimer.
10 4c52d5bf Ilias Tsitsimpis
#
11 4c52d5bf Ilias Tsitsimpis
#   2. Redistributions in binary form must reproduce the above
12 4c52d5bf Ilias Tsitsimpis
#      copyright notice, this list of conditions and the following
13 4c52d5bf Ilias Tsitsimpis
#      disclaimer in the documentation and/or other materials
14 4c52d5bf Ilias Tsitsimpis
#      provided with the distribution.
15 4c52d5bf Ilias Tsitsimpis
#
16 4c52d5bf Ilias Tsitsimpis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 4c52d5bf Ilias Tsitsimpis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 4c52d5bf Ilias Tsitsimpis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 4c52d5bf Ilias Tsitsimpis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 4c52d5bf Ilias Tsitsimpis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 4c52d5bf Ilias Tsitsimpis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 4c52d5bf Ilias Tsitsimpis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 4c52d5bf Ilias Tsitsimpis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 4c52d5bf Ilias Tsitsimpis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 4c52d5bf Ilias Tsitsimpis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 4c52d5bf Ilias Tsitsimpis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 4c52d5bf Ilias Tsitsimpis
# POSSIBILITY OF SUCH DAMAGE.
28 4c52d5bf Ilias Tsitsimpis
#
29 4c52d5bf Ilias Tsitsimpis
# The views and conclusions contained in the software and
30 4c52d5bf Ilias Tsitsimpis
# documentation are those of the authors and should not be
31 4c52d5bf Ilias Tsitsimpis
# interpreted as representing official policies, either expressed
32 4c52d5bf Ilias Tsitsimpis
# or implied, of GRNET S.A.
33 4c52d5bf Ilias Tsitsimpis
34 4c52d5bf Ilias Tsitsimpis
"""
35 4c52d5bf Ilias Tsitsimpis
This is the burnin class that tests the Astakos functionality
36 4c52d5bf Ilias Tsitsimpis

37 4c52d5bf Ilias Tsitsimpis
"""
38 4c52d5bf Ilias Tsitsimpis
39 4c52d5bf Ilias Tsitsimpis
from kamaki.clients.compute import ComputeClient
40 4c52d5bf Ilias Tsitsimpis
from kamaki.clients import ClientError
41 4c52d5bf Ilias Tsitsimpis
42 12ef696f Ilias Tsitsimpis
from synnefo_tools.burnin import common
43 4c52d5bf Ilias Tsitsimpis
44 4c52d5bf Ilias Tsitsimpis
45 9355a604 Ilias Tsitsimpis
# pylint: disable=too-many-public-methods
46 6f2b9836 Ilias Tsitsimpis
class AstakosTestSuite(common.BurninTests):
47 4c52d5bf Ilias Tsitsimpis
    """Test Astakos functionality"""
48 fe15cd00 Ilias Tsitsimpis
    def test_001_unauthorized_access(self):
49 6f2b9836 Ilias Tsitsimpis
        """Test that access without a valid token fails"""
50 4c52d5bf Ilias Tsitsimpis
        false_token = "12345"
51 6f2b9836 Ilias Tsitsimpis
        self.info("Will use token %s", false_token)
52 12ef696f Ilias Tsitsimpis
        client = ComputeClient(self.clients.compute_url, false_token)
53 12ef696f Ilias Tsitsimpis
        client.CONNECTION_RETRY_LIMIT = self.clients.retry
54 4c52d5bf Ilias Tsitsimpis
55 4c52d5bf Ilias Tsitsimpis
        with self.assertRaises(ClientError) as cl_error:
56 4c52d5bf Ilias Tsitsimpis
            client.list_servers()
57 4c52d5bf Ilias Tsitsimpis
            self.assertEqual(cl_error.exception.status, 401)
58 4c52d5bf Ilias Tsitsimpis
59 fe15cd00 Ilias Tsitsimpis
    def test_002_name2uuid(self):
60 6f2b9836 Ilias Tsitsimpis
        """Test that usernames2uuids and uuids2usernames are complementary"""
61 6f2b9836 Ilias Tsitsimpis
        our_uuid = self._get_uuid()
62 4c52d5bf Ilias Tsitsimpis
63 eca500f3 Ilias Tsitsimpis
        given_name = self.clients.astakos.get_usernames([our_uuid])
64 6f2b9836 Ilias Tsitsimpis
        self.info("uuids2usernames returned %s", given_name)
65 6f2b9836 Ilias Tsitsimpis
        self.assertIn(our_uuid, given_name)
66 6f2b9836 Ilias Tsitsimpis
67 eca500f3 Ilias Tsitsimpis
        given_uuid = self.clients.astakos.get_uuids([given_name[our_uuid]])
68 6f2b9836 Ilias Tsitsimpis
        self.info("usernames2uuids returned %s", given_uuid)
69 6f2b9836 Ilias Tsitsimpis
        self.assertIn(given_name[our_uuid], given_uuid)
70 6f2b9836 Ilias Tsitsimpis
71 6f2b9836 Ilias Tsitsimpis
        self.assertEqual(given_uuid[given_name[our_uuid]], our_uuid)