~ubuntu-branches/debian/stretch/waagent/stretch

« back to all changes in this revision

Viewing changes to tests/test_ovfxml.py

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2016-02-01 13:11:28 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20160201131128-4wxc2tklmq3x40xe
Tags: 2.1.2-1
* New upstream version.
* Depend on host, needed by Microsofts custom script stuff.
* Use cloud-init:
  - Use Ubuntu provisioning handler, disable provisioning.
  - Depend on new enough version of cloud-init.
  - Update dependencies in init script and service.
  - Disable recursive agent invocation and hostname bounce in clout-init.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# http://msdn.microsoft.com/en-us/library/cc227282%28PROT.10%29.aspx
19
19
# http://msdn.microsoft.com/en-us/library/cc227259%28PROT.13%29.aspx
20
20
 
21
 
import env
 
21
import tests.env
22
22
import tests.tools as tools
23
23
import uuid
24
24
import unittest
25
25
import os
26
26
import json
 
27
from azurelinuxagent.future import text
27
28
import azurelinuxagent.protocol.ovfenv as ovfenv
28
29
 
29
 
ExtensionsConfigSample="""
 
30
ExtensionsConfigSample="""\
 
31
<?xml version="1.0" encoding="utf-8"?>
30
32
 <Environment xmlns="http://schemas.dmtf.org/ovf/environment/1" xmlns:oe="http://schemas.dmtf.org/ovf/environment/1" xmlns:wa="http://schemas.microsoft.com/windowsazure" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
31
33
    <wa:ProvisioningSection>
32
34
      <wa:Version>1.0</wa:Version>
41
43
            <PublicKey>
42
44
              <Fingerprint>EB0C0AB4B2D5FC35F2F0658D19F44C8283E2DD62</Fingerprint>
43
45
              <Path>$HOME/UserName/.ssh/authorized_keys</Path>
 
46
              <Value>ssh-rsa AAAANOTAREALKEY== foo@bar.local</Value>
44
47
            </PublicKey>
45
48
          </PublicKeys>
46
49
          <KeyPairs>
59
62
class TestOvf(unittest.TestCase):
60
63
    def test_ovf(self):
61
64
        config = ovfenv.OvfEnv(ExtensionsConfigSample)
62
 
        self.assertEquals(1, config.getMajorVersion())
63
 
        self.assertEquals(0, config.getMinorVersion())
64
 
        self.assertEquals("HostName", config.getComputerName())
65
 
        self.assertEquals("UserName", config.getUserName())
66
 
        self.assertEquals("UserPassword", config.getUserPassword())
67
 
        self.assertEquals(False, config.getDisableSshPasswordAuthentication())
68
 
        self.assertEquals("CustomData", config.getCustomData())
69
 
        self.assertNotEquals(None, config.getSshPublicKeys())
70
 
        self.assertEquals(1, len(config.getSshPublicKeys()))
71
 
        self.assertNotEquals(None, config.getSshKeyPairs())
72
 
        self.assertEquals(1, len(config.getSshKeyPairs()))
 
65
        self.assertEquals("HostName", config.hostname)
 
66
        self.assertEquals("UserName", config.username)
 
67
        self.assertEquals("UserPassword", config.user_password)
 
68
        self.assertEquals(False, config.disable_ssh_password_auth)
 
69
        self.assertEquals("CustomData", config.customdata)
 
70
        self.assertNotEquals(None, config.ssh_pubkeys)
 
71
        self.assertEquals(1, len(config.ssh_pubkeys))
 
72
        pubkey = config.ssh_pubkeys[0]
 
73
        path, fingerprint, value = pubkey
 
74
        self.assertEquals(path, "$HOME/UserName/.ssh/authorized_keys")
 
75
        self.assertEquals(fingerprint, "EB0C0AB4B2D5FC35F2F0658D19F44C8283E2DD62"),
 
76
        self.assertEquals(value, "ssh-rsa AAAANOTAREALKEY== foo@bar.local")
 
77
        self.assertNotEquals(None, config.ssh_keypairs)
 
78
        self.assertEquals(1, len(config.ssh_keypairs))
73
79
        
74
80
if __name__ == '__main__':
75
81
    unittest.main()