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

« back to all changes in this revision

Viewing changes to tests/test_hostingenv.py

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2016-02-11 16:40:04 UTC
  • mfrom: (1.2.3)
  • Revision ID: package-import@ubuntu.com-20160211164004-m9chank2yihdviil
Tags: 2.1.3-1
* New upstream version.
* Only create /var/lib/waagent on initial installation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2014 Microsoft Corporation
2
 
#
3
 
# Licensed under the Apache License, Version 2.0 (the "License");
4
 
# you may not use this file except in compliance with the License.
5
 
# You may obtain a copy of the License at
6
 
#
7
 
#     http://www.apache.org/licenses/LICENSE-2.0
8
 
#
9
 
# Unless required by applicable law or agreed to in writing, software
10
 
# distributed under the License is distributed on an "AS IS" BASIS,
11
 
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 
# See the License for the specific language governing permissions and
13
 
# limitations under the License.
14
 
#
15
 
# Requires Python 2.4+ and Openssl 1.0+
16
 
#
17
 
# Implements parts of RFC 2131, 1541, 1497 and
18
 
# http://msdn.microsoft.com/en-us/library/cc227282%28PROT.10%29.aspx
19
 
# http://msdn.microsoft.com/en-us/library/cc227259%28PROT.13%29.aspx
20
 
 
21
 
import tests.env
22
 
import tests.tools as tools
23
 
import uuid
24
 
import unittest
25
 
import os
26
 
import azurelinuxagent.protocol.v1 as v1
27
 
 
28
 
hosting_env_sample=u"""
29
 
 <HostingEnvironmentConfig version="1.0.0.0" goalStateIncarnation="1">
30
 
   <StoredCertificates>
31
 
     <StoredCertificate name="Stored0Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" certificateId="sha1:C093FA5CD3AAE057CB7C4E04532B2E16E07C26CA" storeName="My" configurationLevel="System" />
32
 
   </StoredCertificates>
33
 
   <Deployment name="db00a7755a5e4e8a8fe4b19bc3b330c3" guid="{ce5a036f-5c93-40e7-8adf-2613631008ab}" incarnation="2">
34
 
     <Service name="MyVMRoleService" guid="{00000000-0000-0000-0000-000000000000}" />
35
 
     <ServiceInstance name="db00a7755a5e4e8a8fe4b19bc3b330c3.1" guid="{d113f4d7-9ead-4e73-b715-b724b5b7842c}" />
36
 
   </Deployment>
37
 
   <Incarnation number="1" instance="MachineRole_IN_0" guid="{a0faca35-52e5-4ec7-8fd1-63d2bc107d9b}" />
38
 
   <Role guid="{73d95f1c-6472-e58e-7a1a-523554e11d46}" name="MachineRole" hostingEnvironmentVersion="1" software="" softwareType="ApplicationPackage" entryPoint="" parameters="" settleTimeSeconds="10" />
39
 
   <HostingEnvironmentSettings name="full" runtime="rd_fabric_stable.110217-1402.runtimePackage_1.0.0.8.zip">
40
 
     <CAS mode="full" />
41
 
     <PrivilegeLevel mode="max" />
42
 
     <AdditionalProperties><CgiHandlers></CgiHandlers></AdditionalProperties>
43
 
   </HostingEnvironmentSettings>
44
 
   <ApplicationSettings>
45
 
     <Setting name="__ModelData" value="&lt;m role=&quot;MachineRole&quot; xmlns=&quot;urn:azure:m:v1&quot;>&lt;r name=&quot;MachineRole&quot;>&lt;e name=&quot;a&quot; />&lt;e name=&quot;b&quot; />&lt;e name=&quot;Microsoft.WindowsAzure.Plugins.RemoteAccess.Rdp&quot; />&lt;e name=&quot;Microsoft.WindowsAzure.Plugins.RemoteForwarder.RdpInput&quot; />&lt;/r>&lt;/m>" />
46
 
     <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=http;AccountName=osimages;AccountKey=DNZQ..." />
47
 
     <Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" />
48
 
   </ApplicationSettings>
49
 
   <ResourceReferences>
50
 
     <Resource name="DiagnosticStore" type="directory" request="Microsoft.Cis.Fabric.Controller.Descriptions.ServiceDescription.Data.Policy" sticky="true" size="1" path="db00a7755a5e4e8a8fe4b19bc3b330c3.MachineRole.DiagnosticStore\" disableQuota="false" />
51
 
   </ResourceReferences>
52
 
 </HostingEnvironmentConfig>
53
 
"""
54
 
 
55
 
class TestHostingEvn(unittest.TestCase):
56
 
    def test_hosting_env(self):
57
 
        hosting_env = v1.HostingEnv(hosting_env_sample)
58
 
        self.assertNotEquals(None, hosting_env)
59
 
        self.assertEquals("MachineRole_IN_0", hosting_env.vm_name)
60
 
        self.assertEquals("MachineRole", hosting_env.role_name)
61
 
        self.assertEquals("db00a7755a5e4e8a8fe4b19bc3b330c3", 
62
 
                          hosting_env.deployment_name)
63
 
 
64
 
   
65
 
if __name__ == '__main__':
66
 
    unittest.main()