~ubuntu-branches/ubuntu/precise/maas/precise-security

« back to all changes in this revision

Viewing changes to src/provisioningserver/tests/test_cluster_config.py

Tags: 1.2+bzr1373+dfsg-0ubuntu1~12.04.4
* SECURITY UPDATE: failure to authenticate downloaded content (LP: #1039513)
  - debian/patches/CVE-2013-1058.patch: Authenticate downloaded files with
    GnuPG and MD5SUM files. Thanks to Julian Edwards.
  - CVE-2013-1058
* SECURITY UPDATE: configuration options may be loaded from current working
  directory (LP: #1158425)
  - debian/patches/CVE-2013-1057-1-2.patch: Do not load configuration
    options from the current working directory. Thanks to Julian Edwards.
  - CVE-2013-1057

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2012 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
"""Tests for `provisioningserver.cluster_config`."""
 
5
 
 
6
from __future__ import (
 
7
    absolute_import,
 
8
    print_function,
 
9
    unicode_literals,
 
10
    )
 
11
 
 
12
__metaclass__ = type
 
13
__all__ = []
 
14
 
 
15
from fixtures import EnvironmentVariableFixture
 
16
from maastesting.factory import factory
 
17
from maastesting.testcase import TestCase
 
18
from provisioningserver.cluster_config import (
 
19
    get_cluster_uuid,
 
20
    get_cluster_variable,
 
21
    get_maas_url,
 
22
    )
 
23
 
 
24
 
 
25
class TestClusterConfig(TestCase):
 
26
 
 
27
    def test_get_cluster_variable_reads_env(self):
 
28
        var = factory.make_name('variable')
 
29
        value = factory.make_name('value')
 
30
        self.useFixture(EnvironmentVariableFixture(var, value))
 
31
        self.assertEqual(value, get_cluster_variable(var))
 
32
 
 
33
    def test_get_cluster_variable_fails_if_not_set(self):
 
34
        self.assertRaises(
 
35
            AssertionError,
 
36
            get_cluster_variable, factory.make_name('nonexistent-variable'))
 
37
 
 
38
    def test_get_cluster_uuid_reads_CLUSTER_UUID(self):
 
39
        uuid = factory.make_name('uuid')
 
40
        self.useFixture(EnvironmentVariableFixture('CLUSTER_UUID', uuid))
 
41
        self.assertEqual(uuid, get_cluster_uuid())
 
42
 
 
43
    def test_get_maas_url_reads_MAAS_URL(self):
 
44
        maas_url = factory.make_name('maas_url')
 
45
        self.useFixture(EnvironmentVariableFixture('MAAS_URL', maas_url))
 
46
        self.assertEqual(maas_url, get_maas_url())