Skip to content

Commit dffb4a2

Browse files
author
Samuel Anudeep
committed
Merge pull request #180 from MabOneSdk/anudeeb-dev1
Tests Base RS Backup
2 parents 5e9efae + d010729 commit dffb4a2

File tree

9 files changed

+388
-8
lines changed

9 files changed

+388
-8
lines changed

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Properties/AssemblyInfo.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
using System.Reflection;
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Reflection;
216
using System.Runtime.CompilerServices;
317
using System.Runtime.InteropServices;
418

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.HydraAdapter/Properties/AssemblyInfo.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
using System.Reflection;
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Reflection;
216
using System.Runtime.CompilerServices;
317
using System.Runtime.InteropServices;
418

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/Properties/AssemblyInfo.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
using System.Reflection;
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Reflection;
216
using System.Runtime.CompilerServices;
317
using System.Runtime.InteropServices;
418

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/Properties/AssemblyInfo.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
using System.Reflection;
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Reflection;
216
using System.Runtime.CompilerServices;
317
using System.Runtime.InteropServices;
418

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{65E15D74-1E24-4600-8671-D0B420524B17}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Commands.RecoveryServices.Backup.Test</RootNamespace>
11+
<AssemblyName>Commands.RecoveryServices.Backup.Test</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="Hyak.Common">
34+
<HintPath>..\..\..\packages\Hyak.Common.1.0.3\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
35+
</Reference>
36+
<Reference Include="Microsoft.Azure.Common">
37+
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
38+
</Reference>
39+
<Reference Include="Microsoft.Azure.Common.Authentication">
40+
<HintPath>..\..\..\packages\Microsoft.Azure.Common.Authentication.1.6.1-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
41+
</Reference>
42+
<Reference Include="Microsoft.Azure.Management.RecoveryServicesBackupManagement">
43+
<HintPath>..\Commands.RecoveryServices.Backup.HydraAdapter\Resources\Microsoft.Azure.Management.RecoveryServicesBackupManagement.dll</HintPath>
44+
</Reference>
45+
<Reference Include="Microsoft.Azure.Test.Framework, Version=1.0.5568.26003, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
46+
<SpecificVersion>False</SpecificVersion>
47+
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5799.28345-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
48+
</Reference>
49+
<Reference Include="Microsoft.Azure.Test.HttpRecorder">
50+
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5799.28345-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
51+
</Reference>
52+
<Reference Include="System" />
53+
<Reference Include="System.Configuration" />
54+
<Reference Include="System.Core" />
55+
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
56+
<SpecificVersion>False</SpecificVersion>
57+
<HintPath>C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll</HintPath>
58+
</Reference>
59+
<Reference Include="System.Net.Http" />
60+
<Reference Include="System.Xml.Linq" />
61+
<Reference Include="System.Data.DataSetExtensions" />
62+
<Reference Include="Microsoft.CSharp" />
63+
<Reference Include="System.Data" />
64+
<Reference Include="System.Xml" />
65+
</ItemGroup>
66+
<ItemGroup>
67+
<Compile Include="Properties\AssemblyInfo.cs" />
68+
<Compile Include="ScenarioTests\TestsBase.cs" />
69+
</ItemGroup>
70+
<ItemGroup>
71+
<Folder Include="SessionRecords\" />
72+
</ItemGroup>
73+
<ItemGroup>
74+
<ProjectReference Include="..\..\Common\Commands.ScenarioTests.ResourceManager.Common\Commands.ScenarioTests.ResourceManager.Common.csproj">
75+
<Project>{3436a126-edc9-4060-8952-9a1be34cdd95}</Project>
76+
<Name>Commands.ScenarioTests.ResourceManager.Common</Name>
77+
</ProjectReference>
78+
</ItemGroup>
79+
<ItemGroup>
80+
<WCFMetadata Include="Service References\" />
81+
</ItemGroup>
82+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
83+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
84+
Other similar extension points exist, see Microsoft.Common.targets.
85+
<Target Name="BeforeBuild">
86+
</Target>
87+
<Target Name="AfterBuild">
88+
</Target>
89+
-->
90+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Reflection;
16+
using System.Runtime.CompilerServices;
17+
using System.Runtime.InteropServices;
18+
19+
// General Information about an assembly is controlled through the following
20+
// set of attributes. Change these attribute values to modify the information
21+
// associated with an assembly.
22+
[assembly: AssemblyTitle("Commands.RecoveryServices.Backup.Test")]
23+
[assembly: AssemblyDescription("")]
24+
[assembly: AssemblyConfiguration("")]
25+
[assembly: AssemblyCompany("")]
26+
[assembly: AssemblyProduct("Commands.RecoveryServices.Backup.Test")]
27+
[assembly: AssemblyCopyright("Copyright © 2016")]
28+
[assembly: AssemblyTrademark("")]
29+
[assembly: AssemblyCulture("")]
30+
31+
// Setting ComVisible to false makes the types in this assembly not visible
32+
// to COM components. If you need to access a type in this assembly from
33+
// COM, set the ComVisible attribute to true on that type.
34+
[assembly: ComVisible(false)]
35+
36+
// The following GUID is for the ID of the typelib if this project is exposed to COM
37+
[assembly: Guid("ef0e42be-7498-4dfa-a544-ff268a1c2c0d")]
38+
39+
// Version information for an assembly consists of the following four values:
40+
//
41+
// Major Version
42+
// Minor Version
43+
// Build Number
44+
// Revision
45+
//
46+
// You can specify all the values or you can default the Build and Revision Numbers
47+
// by using the '*' as shown below:
48+
// [assembly: AssemblyVersion("1.0.*")]
49+
[assembly: AssemblyVersion("1.0.0.0")]
50+
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Common.Authentication;
16+
using Microsoft.Azure.Test;
17+
using Microsoft.Azure.Test.HttpRecorder;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using System;
20+
using System.Configuration;
21+
using System.Net;
22+
using System.Net.Http;
23+
using System.Net.Security;
24+
using System.Reflection;
25+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
26+
using Microsoft.Azure.Management.RecoveryServices.Backup;
27+
using Hyak.Common;
28+
29+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests
30+
{
31+
public abstract class RecoveryServicesBackupTestsBase : RMTestBase
32+
{
33+
CSMTestEnvironmentFactory csmTestFactory;
34+
EnvironmentSetupHelper helper;
35+
36+
protected RecoveryServicesBackupManagementClient RsBackupClient { get; private set; }
37+
38+
protected string ResourceNamespace { get; private set; }
39+
40+
protected RecoveryServicesBackupTestsBase()
41+
{
42+
this.helper = new EnvironmentSetupHelper();
43+
this.csmTestFactory = new CSMTestEnvironmentFactory();
44+
ResourceNamespace = "Microsoft.RecoveryServices";
45+
}
46+
47+
protected void SetResourceNamespace(string resourceNamespace)
48+
{
49+
ResourceNamespace = resourceNamespace;
50+
}
51+
52+
protected void SetupManagementClients()
53+
{
54+
RsBackupClient = GetRsBackupClient();
55+
56+
helper.SetupSomeOfManagementClients(RsBackupClient);
57+
}
58+
59+
protected void RunPowerShellTest(params string[] scripts)
60+
{
61+
using (UndoContext context = UndoContext.Current)
62+
{
63+
context.Start(TestUtilities.GetCallingClass(2), TestUtilities.GetCurrentMethodName(2));
64+
65+
SetupManagementClients();
66+
67+
helper.SetupEnvironment(AzureModule.AzureResourceManager);
68+
helper.SetupModules(AzureModule.AzureResourceManager,
69+
"ScenarioTests\\" + this.GetType().Name + ".ps1",
70+
helper.RMProfileModule,
71+
helper.GetRMModulePath("AzureRM.Backup.psd1")
72+
);
73+
helper.RunPowerShellTest(scripts);
74+
}
75+
}
76+
77+
private RecoveryServicesBackupManagementClient GetRsBackupClient()
78+
{
79+
var factory = (TestEnvironmentFactory)new CSMTestEnvironmentFactory();
80+
81+
var testEnvironment = factory.GetTestEnvironment();
82+
83+
ServicePointManager.ServerCertificateValidationCallback = IgnoreCertificateErrorHandler;
84+
85+
RecoveryServicesBackupManagementClient client;
86+
87+
if (testEnvironment.UsesCustomUri())
88+
{
89+
client = new RecoveryServicesBackupManagementClient(
90+
ResourceNamespace,
91+
testEnvironment.Credentials as SubscriptionCloudCredentials,
92+
testEnvironment.BaseUri);
93+
}
94+
95+
else
96+
{
97+
client = new RecoveryServicesBackupManagementClient(
98+
ResourceNamespace,
99+
testEnvironment.Credentials as SubscriptionCloudCredentials);
100+
}
101+
102+
return GetServiceClient<RecoveryServicesBackupManagementClient>(factory, client);
103+
}
104+
105+
public static T GetServiceClient<T>(TestEnvironmentFactory factory, RecoveryServicesBackupManagementClient client) where T : class
106+
{
107+
TestEnvironment testEnvironment = factory.GetTestEnvironment();
108+
109+
HttpMockServer instance;
110+
try
111+
{
112+
instance = HttpMockServer.CreateInstance();
113+
}
114+
catch (ApplicationException)
115+
{
116+
HttpMockServer.Initialize("TestEnvironment", "InitialCreation");
117+
instance = HttpMockServer.CreateInstance();
118+
}
119+
T obj2 = typeof(T).GetMethod("WithHandler", new Type[1]
120+
{
121+
typeof (DelegatingHandler)
122+
}).Invoke((object)client, new object[1]
123+
{
124+
(object) instance
125+
}) as T;
126+
127+
if (HttpMockServer.Mode == HttpRecorderMode.Record)
128+
{
129+
HttpMockServer.Variables[TestEnvironment.SubscriptionIdKey] = testEnvironment.SubscriptionId;
130+
}
131+
132+
if (HttpMockServer.Mode == HttpRecorderMode.Playback)
133+
{
134+
PropertyInfo property1 = typeof(T).GetProperty("LongRunningOperationInitialTimeout", typeof(int));
135+
PropertyInfo property2 = typeof(T).GetProperty("LongRunningOperationRetryTimeout", typeof(int));
136+
if (property1 != (PropertyInfo)null && property2 != (PropertyInfo)null)
137+
{
138+
property1.SetValue((object)obj2, (object)0);
139+
property2.SetValue((object)obj2, (object)0);
140+
}
141+
}
142+
return obj2;
143+
}
144+
145+
private static bool IgnoreCertificateErrorHandler
146+
(object sender,
147+
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
148+
System.Security.Cryptography.X509Certificates.X509Chain chain,
149+
SslPolicyErrors sslPolicyErrors)
150+
{
151+
return true;
152+
}
153+
}
154+
}

src/ResourceManager/RecoveryServices.Backup/Properties/AssemblyInfo.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
using System.Reflection;
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Reflection;
216
using System.Runtime.CompilerServices;
317
using System.Runtime.InteropServices;
418

0 commit comments

Comments
 (0)