CAL and SDNAL cleanup for failure cases in accounts
[osm/SO.git] / charms / layers / sshproxy / tests / 10-deploy
1 ##
2 # Copyright 2016 Canonical Ltd.
3 # All rights reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may
6 # not use this file except in compliance with the License. You may obtain
7 # a copy of the License at
8 #
9 #         http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # License for the specific language governing permissions and limitations
15 # under the License.
16 ##
17
18 #!/usr/bin/python3
19
20 import amulet
21 import requests
22 import unittest
23 import string
24 import random
25
26
27 class TestCharm(unittest.TestCase):
28     user = None
29     passwd = None
30
31     def id_generator(self, size=6, chars=string.ascii_uppercase + string.digits):
32         return ''.join(random.choice(chars) for _ in range(size))
33
34     def setUp(self):
35
36         # Setup random user/password
37         self.user = self.id_generator()
38         self.passwd = self.id_generator()
39
40         self.d = amulet.Deployment()
41
42         self.d.add('sshproxy')
43         self.d.add('ubuntu')
44
45         self.d.expose('sshproxy')
46
47         self.d.setup(timeout=900)
48         self.d.sentry.wait()
49
50         # Add
51         ubuntu_0 = d.sentry['ubuntu'][0]
52         ubuntu_0.ssh("sudo adduser {}".format(self.user))
53         ubuntu_0.ssh("echo '{}' | sudo passwd {} --stdin".format(self.passwd, self.user))
54
55         self.unit = self.d.sentry['sshproxy'][0]
56
57     def test_service(self):
58
59         # Configure the unit
60
61         # Run a command
62
63         # Verify the output
64
65         # test we can access over http
66         # page = requests.get('http://{}'.format(self.unit.info['public-address']))
67         # self.assertEqual(page.status_code, 200)
68         # Now you can use self.d.sentry[SERVICE][UNIT] to address each of the units and perform
69         # more in-depth steps. Each self.d.sentry[SERVICE][UNIT] has the following methods:
70         # - .info - An array of the information of that unit from Juju
71         # - .file(PATH) - Get the details of a file on that unit
72         # - .file_contents(PATH) - Get plain text output of PATH file from that unit
73         # - .directory(PATH) - Get details of directory
74         # - .directory_contents(PATH) - List files and folders in PATH on that unit
75         # - .relation(relation, service:rel) - Get relation data from return service
76         pass