summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2013-03-01 14:56:55 -0500
committerScott Moser <smoser@ubuntu.com>2013-03-01 14:56:55 -0500
commitff0a34876dc0ce29b762ffd7fcdbfa80308e5aae (patch)
tree3e83f7944c702580f276f545a48ac69016e14f1e /tests
parentceec6724143e950d6ceb9ea0758dbfd1ad33921a (diff)
downloadvyos-cloud-init-ff0a34876dc0ce29b762ffd7fcdbfa80308e5aae.tar.gz
vyos-cloud-init-ff0a34876dc0ce29b762ffd7fcdbfa80308e5aae.zip
change parser.parse 'default_opts' to 'options'
Now, parser.parse specifies options that override any options found, rather than just being default options. There could still potentially be a user for default_options, but since we're not using them anywhere, I've dropped it. The difference is that in setting up the root user, we're now insisting that all keys that go in there have the key_prefix, even if the key content had other options. I think this is actually the commit that fixes LP: #1136343.
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_sshutil.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/tests/unittests/test_sshutil.py b/tests/unittests/test_sshutil.py
index 4564d9be..2415d06f 100644
--- a/tests/unittests/test_sshutil.py
+++ b/tests/unittests/test_sshutil.py
@@ -62,7 +62,7 @@ class TestAuthKeyLineParser(TestCase):
self.assertFalse(key.comment)
self.assertEqual(key.keytype, ktype)
- def test_parse_with_options(self):
+ def test_parse_with_keyoptions(self):
# test key line with options in it
parser = ssh_util.AuthKeyLineParser()
options = TEST_OPTIONS
@@ -77,18 +77,24 @@ class TestAuthKeyLineParser(TestCase):
self.assertEqual(key.comment, comment)
self.assertEqual(key.keytype, ktype)
- def test_parse_with_defopt(self):
+ def test_parse_with_options_passed_in(self):
# test key line with key type and base64 only
parser = ssh_util.AuthKeyLineParser()
- for ktype in ['rsa', 'ecdsa', 'dsa']:
- content = VALID_CONTENT[ktype]
- line = ' '.join((ktype, content,))
- myopts = "no-port-forwarding,no-agent-forwarding"
- key = parser.parse(line, myopts)
- self.assertEqual(key.base64, content)
- self.assertEqual(key.options, myopts)
- self.assertFalse(key.comment)
- self.assertEqual(key.keytype, ktype)
+ baseline = ' '.join(("rsa", VALID_CONTENT['rsa'], "user@host"))
+ myopts = "no-port-forwarding,no-agent-forwarding"
+
+ key = parser.parse("allowedopt" + " " + baseline)
+ self.assertEqual(key.options, "allowedopt")
+
+ key = parser.parse("overridden_opt " + baseline, options=myopts)
+ self.assertEqual(key.options, myopts)
+
+ def test_parse_invalid_keytype(self):
+ parser = ssh_util.AuthKeyLineParser()
+ key = parser.parse(' '.join(["badkeytype", VALID_CONTENT['rsa']]))
+
+ self.assertFalse(key.valid())
+
# vi: ts=4 expandtab