~ubuntu-branches/ubuntu/quantal/maas/quantal-security

« back to all changes in this revision

Viewing changes to src/maasserver/tests/test_config.py

  • Committer: Package Import Robot
  • Author(s): Seth Arnold
  • Date: 2013-11-01 17:15:48 UTC
  • mfrom: (20.1.2 quantal-proposed)
  • Revision ID: package-import@ubuntu.com-20131101171548-2zswm101618z3kn6
Tags: 1.2+bzr1373+dfsg-0ubuntu1.1
* 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:
16
16
 
17
17
from fixtures import TestWithFixtures
18
18
from maasserver.models import Config
19
 
from maasserver.models.config import (
20
 
    DEFAULT_CONFIG,
21
 
    get_default_config,
22
 
    )
 
19
import maasserver.models.config
 
20
from maasserver.models.config import get_default_config
23
21
from maasserver.testing.factory import factory
24
22
from maasserver.testing.testcase import TestCase
25
23
 
31
29
        default_config = get_default_config()
32
30
        self.assertEqual(gethostname(), default_config['maas_name'])
33
31
 
 
32
    def test_defaults(self):
 
33
        expected = get_default_config()
 
34
        observed = {
 
35
            name: Config.objects.get_config(name)
 
36
            for name in expected
 
37
            }
 
38
        self.assertEqual(expected, observed)
 
39
 
34
40
 
35
41
class CallRecorder:
36
42
    """A utility class which tracks the calls to its 'call' method and
63
69
    def test_manager_get_config_not_found_in_default_config(self):
64
70
        name = factory.getRandomString()
65
71
        value = factory.getRandomString()
66
 
        DEFAULT_CONFIG[name] = value
 
72
        self.patch(maasserver.models.config, "DEFAULT_CONFIG", {name: value})
67
73
        config = Config.objects.get_config(name, None)
68
74
        self.assertEqual(value, config)
69
75
 
70
76
    def test_default_config_cannot_be_changed(self):
71
77
        name = factory.getRandomString()
72
 
        DEFAULT_CONFIG[name] = {'key': 'value'}
 
78
        self.patch(
 
79
            maasserver.models.config, "DEFAULT_CONFIG",
 
80
            {name: {'key': 'value'}})
73
81
        config = Config.objects.get_config(name)
74
82
        config.update({'key2': 'value2'})
75
83