1
# Copyright 2014 Microsoft Corporation
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
7
# http://www.apache.org/licenses/LICENSE-2.0
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.
15
# Requires Python 2.4+ and Openssl 1.0+
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
22
import tests.tools as tools
26
import azurelinuxagent.protocol.v1 as v1
28
hosting_env_sample=u"""
29
<HostingEnvironmentConfig version="1.0.0.0" goalStateIncarnation="1">
31
<StoredCertificate name="Stored0Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" certificateId="sha1:C093FA5CD3AAE057CB7C4E04532B2E16E07C26CA" storeName="My" configurationLevel="System" />
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}" />
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">
41
<PrivilegeLevel mode="max" />
42
<AdditionalProperties><CgiHandlers></CgiHandlers></AdditionalProperties>
43
</HostingEnvironmentSettings>
45
<Setting name="__ModelData" value="<m role="MachineRole" xmlns="urn:azure:m:v1"><r name="MachineRole"><e name="a" /><e name="b" /><e name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Rdp" /><e name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.RdpInput" /></r></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>
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" />
52
</HostingEnvironmentConfig>
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)
65
if __name__ == '__main__':