Skip to content
Merged
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
ee4de5f
Adding hydra changes for other cmdlets part 1
Jul 7, 2015
4aba273
Adding hydra test cases
Jul 8, 2015
c82ea41
Removed ContainerInfo and depending only on CSMContainerResponse
Jul 8, 2015
6857479
Deleting the container info model files
Jul 8, 2015
f837a2c
FI from csp-artemis
Jul 13, 2015
35c3677
Deleting unwanted files
Jul 13, 2015
561354d
sdknetbackupandRestore
panbha Jul 15, 2015
7a9ee68
Merge pull request #36 from MabOneSdk/csm-panbha1
panbha Jul 15, 2015
26ca58e
recoverypoint1
panbha Jul 18, 2015
4c8ee62
recoverypoint3
panbha Jul 18, 2015
0d9acd5
Merge pull request #37 from MabOneSdk/csm-panbha1
panbha Jul 18, 2015
1465664
pikumarandmychanges
panbha Jul 21, 2015
7a5f6bb
Merge pull request #39 from MabOneSdk/csm-panbhacr
panbha Jul 21, 2015
3626db8
missedfiles
panbha Jul 22, 2015
c73a228
Merge pull request #40 from MabOneSdk/csm-panbhacr
panbha Jul 22, 2015
a4b3acc
missedfiles1
panbha Jul 22, 2015
85e7612
Merge pull request #41 from MabOneSdk/csm-panbhacr
panbha Jul 22, 2015
e6224a5
missedfiles2
panbha Jul 22, 2015
b691a62
Merge pull request #42 from MabOneSdk/csm-panbhacr
panbha Jul 22, 2015
ea7d984
missedfile3
panbha Jul 22, 2015
b7573e3
Merge pull request #43 from MabOneSdk/csm-panbhacr
panbha Jul 22, 2015
05b3490
recoverypointId
panbha Jul 22, 2015
b3f3f2f
Merge pull request #44 from MabOneSdk/csm-panbhacr
panbha Jul 22, 2015
6d3191c
backupcamel
panbha Jul 22, 2015
7401f64
recoverycamel
panbha Jul 22, 2015
effb8a7
restorecamel
panbha Jul 22, 2015
f851a82
Merge pull request #45 from MabOneSdk/csm-panbhacr21
panbha Jul 22, 2015
12d0233
Adding Jobs tests file
AditTulasi Jul 23, 2015
8d13797
Merge branch 'csm-master' into csm-adit-branch
AditTulasi Jul 23, 2015
90c26fc
CSM Jobs changes
AditTulasi Jul 23, 2015
8897421
Merge pull request #46 from MabOneSdk/csm-adit-branch
AditTulasi Jul 23, 2015
5890fc8
rp1
panbha Jul 23, 2015
5509500
app
panbha Jul 23, 2015
3bb2bc9
Merge pull request #47 from MabOneSdk/csm-panbhacr21
panbha Jul 23, 2015
e3c58a0
LTR Changes
pragrawa Jul 24, 2015
281f051
Merge Conflict
pragrawa Jul 24, 2015
518374d
Merge Conflict
pragrawa Jul 24, 2015
76743d9
Merge Conflict
pragrawa Jul 24, 2015
0ae05a9
Merge pull request #48 from MabOneSdk/csm-pragrawa
pragrawa Jul 24, 2015
8302653
Merge Conflict
pragrawa Jul 24, 2015
fd3398f
Merge pull request #49 from MabOneSdk/csm-pragrawa
pragrawa Jul 24, 2015
ab5297a
Policy Hydra Test
pragrawa Jul 24, 2015
eca5768
Merge Conflict
pragrawa Jul 24, 2015
af749ff
Merge pull request #50 from MabOneSdk/csm-pragrawa
pragrawa Jul 24, 2015
f543ab7
test cases
pikumarmsft16 Jul 27, 2015
aab279c
LTR Policy changes
pragrawa Jul 27, 2015
9ef967d
Merge pull request #51 from MabOneSdk/csm-pragrawa
pragrawa Jul 27, 2015
b7bfd47
Merge branch 'csm-master' of https://github.com/MabOneSdk/azure-sdk-f…
pikumarmsft16 Jul 31, 2015
b52422a
latest changes
pikumarmsft16 Jul 31, 2015
a4f6def
adding more files
pikumarmsft16 Jul 31, 2015
9a73ea6
Merge pull request #52 from MabOneSdk/csm-pikumar
pikumarmsft16 Jul 31, 2015
616682b
Adding container test cases
mkherani Aug 2, 2015
d31970b
Supporting dual clients
Aug 3, 2015
b1e14d6
Adding MARS Container and Get Container tests
Aug 3, 2015
936f5d6
Adding session records
Aug 3, 2015
085ce88
Adding session records
Aug 3, 2015
0cc03c4
Adding container tests + records
Aug 4, 2015
d48e493
changing type to itemType
pikumarmsft16 Aug 5, 2015
3090dfa
Merge pull request #53 from MabOneSdk/csm-pikumar
pikumarmsft16 Aug 5, 2015
667a47b
Fix for bug 3865084:[SDKBash2]: TaskId is not in correct format for C…
Aug 6, 2015
2f7083d
Fix for bug 3916852:[SDKBash2]: Client request ID is set in the respo…
Aug 6, 2015
626ee17
Fixing jobs test cases
AditTulasi Aug 13, 2015
3150829
hydra recording with csm changes
pikumarmsft16 Aug 14, 2015
cdcd4ca
Merge pull request #54 from MabOneSdk/csm-pikumar
pikumarmsft16 Aug 14, 2015
18d2cbb
Merge from release and taking target files
swatimadhukargit Aug 14, 2015
89a5ded
Generating code from Hyak specs for AzureBackup
swatimadhukargit Aug 14, 2015
56894d4
Fixing failing test cases
swatimadhukargit Aug 15, 2015
1aee963
Merge branch 'release' into csm-master
swatimadhukargit Aug 15, 2015
a48e020
Fixing AzureBackup.sln and TestDependencies.csproj
swatimadhukargit Aug 15, 2015
2d1bba2
Updating client and operations in all test functions
AditTulasi Aug 17, 2015
18b5d72
Disabling failing test cases temporarily
swatimadhukargit Aug 17, 2015
0efb71c
Fixing test cases etc after updating hydra
AditTulasi Aug 17, 2015
7b8244c
Merge pull request #55 from MabOneSdk/csm-master-newclient
AditTulasi Aug 17, 2015
00e6000
Merge pull request #56 from MabOneSdk/csm-master
AditTulasi Aug 17, 2015
d03fa19
Removing locker folder which got added by mistake.
swatimadhukargit Aug 18, 2015
9e72a5a
Increase nuget package version
swatimadhukargit Aug 18, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not put the folder under root, unless you have good reason.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain how you want the folder structure to be ?

// Copyright (c) Microsoft. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

using Microsoft.Azure.Management.BackupServices;
using Microsoft.Azure.Management.BackupServices.Models;
using Microsoft.Azure.Test;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Xunit;

namespace BackupServices.Tests
{
public class AzureBackupItemTests : BackupServicesTestsBase
{
[Fact]
public void EnableAzureBackupProtectionTest()
{
using (UndoContext context = UndoContext.Current)
{
var client = GetServiceClient<BackupServicesManagementClient>();
context.Start();
SetProtectionRequestInput input = new SetProtectionRequestInput();
input.PolicyId = ConfigurationManager.AppSettings["PolicyId"];
input.ProtectableObjects.Add(ConfigurationManager.AppSettings["AzureBackupItemName"]);
input.ProtectableObjectType = ConfigurationManager.AppSettings["DataSourceType"];
var response = client.DataSource.EnableProtection(GetCustomRequestHeaders(), input);
Assert.Equal(HttpStatusCode.Accepted, response.StatusCode);
}
}

[Fact]
public void DisableAzureBackupProtectionTest()
{
using (UndoContext context = UndoContext.Current)
{
var client = GetServiceClient<BackupServicesManagementClient>();
context.Start();
RemoveProtectionRequestInput input1 = new RemoveProtectionRequestInput();
input1.RemoveProtectionOption = "RetainBackupData";
string containerName = ConfigurationManager.AppSettings["ContainerName"];
string dataSourceType = ConfigurationManager.AppSettings["DataSourceType"];
string dataSourceId = ConfigurationManager.AppSettings["DataSourceId"];
var response = client.DataSource.DisableProtection(GetCustomRequestHeaders(),
containerName,
dataSourceType,
dataSourceId,
input1);
Assert.Equal(HttpStatusCode.Accepted, response.StatusCode);
}
}

[Fact]
public void ListAzureBackupItemPOTest()
{
using (UndoContext context = UndoContext.Current)
{
context.Start();

POQueryParameter POQueryParam = new POQueryParameter()
{
Status = null,
Type = null
};

var client = GetServiceClient<BackupServicesManagementClient>();

var response = client.ProtectableObject.ListAsync(POQueryParam, GetCustomRequestHeaders()).Result;

Assert.True(response.ProtectableObject.ResultCount > 0, "Protectable Object Result count can't be less than 1");

foreach (var po in response.ProtectableObject.Objects)
{
Assert.True(!string.IsNullOrEmpty(po.ContainerName), "ContainerName can't be null or empty");
Assert.True(!string.IsNullOrEmpty(po.ContainerType), "ContainerType can't be null or empty");
Assert.True(!string.IsNullOrEmpty(po.FriendlyName), "FriendlyName can't be null or empty");
Assert.True(!string.IsNullOrEmpty(po.Type), "Type can't be null or empty");
Assert.True(!string.IsNullOrEmpty(po.InstanceId), "Name can't be null or empty");
Assert.True(!string.IsNullOrEmpty(po.Name), "Name can't be null or empty");
Assert.True(!string.IsNullOrEmpty(po.ParentContainerFriendlyName), "ParentContainerFriendlyName can't be null or empty");
Assert.True(!string.IsNullOrEmpty(po.ParentContainerName), "ParentContainerName can't be null or empty");
Assert.True(!string.IsNullOrEmpty(po.ProtectionStatus), "ProtectionStatus can't be null or empty");
}

Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
}

[Fact]
public void ListAzureBackupItemDSTest()
{
using (UndoContext context = UndoContext.Current)
{
context.Start();

DataSourceQueryParameter DSQueryParam = new DataSourceQueryParameter()
{
ProtectionStatus = null,
Status = null,
Type = null
};

var client = GetServiceClient<BackupServicesManagementClient>();

var response = client.DataSource.ListAsync(DSQueryParam, GetCustomRequestHeaders()).Result;
foreach (var ds in response.DataSources.Objects)
{
Assert.True(!string.IsNullOrEmpty(ds.ContainerName), "ContainerName can't be null or empty");
Assert.True(!string.IsNullOrEmpty(ds.ContainerType), "ContainerType can't be null or empty");
Assert.True(!string.IsNullOrEmpty(ds.FriendlyName), "FriendlyName can't be null or empty");
Assert.True(!string.IsNullOrEmpty(ds.Type), "Type can't be null or empty");
Assert.True(!string.IsNullOrEmpty(ds.RecoveryPointsCount.ToString()), "RecoveryPointsCount can't be null or empty");
Assert.True(!string.IsNullOrEmpty(ds.ProtectableObjectName), "ProtectableObjectName can't be null or empty");
Assert.True(!string.IsNullOrEmpty(ds.InstanceId), "Name can't be null or empty");
Assert.True(!string.IsNullOrEmpty(ds.Name), "WorkloadType can't be null or empty");
Assert.True(!string.IsNullOrEmpty(ds.ProtectionStatus), "ProtectionStatus can't be null or empty");
Assert.True(!string.IsNullOrEmpty(ds.Status), "Status can't be null or empty"); ;
}

Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Microsoft.Azure.Management.BackupServices.Models;
using Microsoft.Azure.Management.BackupServices;
using Microsoft.Azure.Test;
using System.Net;
using Xunit;
using System.Configuration;
using System;

namespace BackupServices.Tests
{
public class BackUpTests : BackupServicesTestsBase
{
[Fact]
public void TriggerBackUpTest()
{
using (UndoContext context = UndoContext.Current)
{
context.Start();
var client = GetServiceClient<BackupServicesManagementClient>();

string containerName = ConfigurationManager.AppSettings["ContainerName"];
string dataSourceType = ConfigurationManager.AppSettings["DataSourceType"];
string dataSourceId = ConfigurationManager.AppSettings["DataSourceId"];

var response = client.BackUp.TriggerBackUp(GetCustomRequestHeaders(), containerName, dataSourceType, dataSourceId);
Assert.Equal(HttpStatusCode.Accepted, response.StatusCode);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
//
// Copyright (c) Microsoft. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

using System;
using System.Collections.Generic;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Azure.Management.BackupServices;
using Microsoft.Azure.Management.BackupServices.Models;
using Microsoft.Azure.Common.Internals;
using Hyak.Common.TransientFaultHandling;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Xml;
using Xunit;
using Microsoft.Azure.Test;
using Newtonsoft.Json;
using Microsoft.Azure.Test.HttpRecorder;
using System.Configuration;
using Microsoft.Azure;
using System.Reflection;
using System.Net.Http;
using System.Net.Security;

namespace BackupServices.Tests
{
public class BackupServicesTestsBase : TestBase
{
public new static T GetServiceClient<T>() where T : class
{
var factory = (TestEnvironmentFactory)new CSMTestEnvironmentFactory();

var testEnvironment = factory.GetTestEnvironment();
//testEnvironment.BaseUri = new Uri("https://localhost:8443/RdfeProxy.svc/");
ServicePointManager.ServerCertificateValidationCallback = IgnoreCertificateErrorHandler;

BackupServicesManagementClient client;

string resourceName = ConfigurationManager.AppSettings["ResourceName"];
string resourceGroupName = ConfigurationManager.AppSettings["ResourceGroupName"];
if (testEnvironment.UsesCustomUri())
{
client = new BackupServicesManagementClient(
resourceName,
resourceGroupName,
testEnvironment.Credentials as SubscriptionCloudCredentials,
testEnvironment.BaseUri);
}

else
{
client = new BackupServicesManagementClient(
resourceName,
resourceGroupName,
testEnvironment.Credentials as SubscriptionCloudCredentials);
}

return GetServiceClient<T>(factory, client);
}


public static T GetServiceClient<T>(TestEnvironmentFactory factory, BackupServicesManagementClient client) where T : class
{
TestEnvironment testEnvironment = factory.GetTestEnvironment();

HttpMockServer instance;
try
{
instance = HttpMockServer.CreateInstance();
}
catch (ApplicationException)
{
HttpMockServer.Initialize("TestEnvironment", "InitialCreation");
instance = HttpMockServer.CreateInstance();
}
T obj2 = typeof(T).GetMethod("WithHandler", new Type[1]
{
typeof (DelegatingHandler)
}).Invoke((object)client, new object[1]
{
(object) instance
}) as T;

if (HttpMockServer.Mode == HttpRecorderMode.Record)
{
HttpMockServer.Variables[TestEnvironment.SubscriptionIdKey] = testEnvironment.SubscriptionId;
}

if (HttpMockServer.Mode == HttpRecorderMode.Playback)
{
PropertyInfo property1 = typeof(T).GetProperty("LongRunningOperationInitialTimeout", typeof(int));
PropertyInfo property2 = typeof(T).GetProperty("LongRunningOperationRetryTimeout", typeof(int));
if (property1 != (PropertyInfo)null && property2 != (PropertyInfo)null)
{
property1.SetValue((object)obj2, (object)0);
property2.SetValue((object)obj2, (object)0);
}
}
return obj2;
}

private static bool IgnoreCertificateErrorHandler
(object sender,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
}

public static CustomRequestHeaders GetCustomRequestHeaders()
{
return new CustomRequestHeaders()
{
ClientRequestId = Guid.NewGuid().ToString(),
};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using Microsoft.Azure.Management.BackupServices;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license header

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do the same for other files

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The locker folder got added by mistake by one of my teammate. I have removed it.

using Microsoft.Azure.Management.BackupServices.Models;
using Microsoft.Azure.Test;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using System.Configuration;
using BackupServices.Tests.Helpers;

namespace BackupServices.Tests
{
public class ContainerTests : BackupServicesTestsBase
{
[Fact]
public void ListContainersReturnsValidResponseTest()
{
using (UndoContext undoContext = UndoContext.Current)
{
undoContext.Start();

BackupServicesManagementClient client = GetServiceClient<BackupServicesManagementClient>();

ListContainerResponse response = client.Container.List(string.Empty, GetCustomRequestHeaders());

// Response Validation
Assert.NotNull(response);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.True(response.ResultCount > 0, "Should return at least one container");
Assert.True(response.Objects.Count > 0, "Should return at least one container");
}
}

[Fact]
public void RegisterContainersReturnsValidResponseTest()
{
using (UndoContext undoContext = UndoContext.Current)
{
undoContext.Start();

BackupServicesManagementClient client = GetServiceClient<BackupServicesManagementClient>();
string containerName = ConfigurationManager.AppSettings["ContainerName"];
var inputRequest = new RegisterContainerRequestInput();
inputRequest.ContainerType = "IaasVMContainer";
inputRequest.ContainerUniqueNameList = new List<string>();
inputRequest.ContainerUniqueNameList.Add(containerName);

var response = client.Container.Register(inputRequest, GetCustomRequestHeaders());

// Response Validation
Assert.Equal(HttpStatusCode.Accepted, response.StatusCode);
Assert.NotNull(response);
}
}

[Fact]
public void UnRegisterContainersReturnsValidResponseTest()
{
using (UndoContext undoContext = UndoContext.Current)
{
undoContext.Start();

BackupServicesManagementClient client = GetServiceClient<BackupServicesManagementClient>();
string containerName = ConfigurationManager.AppSettings["ContainerName"];
var inputRequest = new UnregisterContainerRequestInput();
inputRequest.ContainerType = "IaasVMContainer";
inputRequest.ContainerUniqueName = containerName;

var response = client.Container.Unregister(inputRequest, GetCustomRequestHeaders());

// Response Validation
Assert.Equal(HttpStatusCode.Accepted, response.StatusCode);
Assert.NotNull(response);
}
}
}
}
Loading