Skip to content

Commit fe09301

Browse files
committed
Fix UTs
1 parent 367d457 commit fe09301

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+110
-156
lines changed

src/Common/Azure.Common.Extensions/Authentication/AdalTokenProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Common.Extensions.Models;
16+
using Microsoft.Azure.Common.Extensions.Properties;
1517
using System;
1618
using System.Security;
1719
using System.Windows.Forms;
18-
using Microsoft.Azure.Common.Extensions.Models;
19-
using Microsoft.Azure.Common.Extensions.Properties;
2020

2121
namespace Microsoft.Azure.Common.Extensions.Authentication
2222
{

src/Common/Azure.Common.Extensions/Authentication/ITokenProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Security;
1615
using Microsoft.Azure.Common.Extensions.Models;
16+
using System.Security;
1717

1818
namespace Microsoft.Azure.Common.Extensions.Authentication
1919
{

src/Common/Azure.Common.Extensions/Authentication/ProtectedFileTokenCache.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.IdentityModel.Clients.ActiveDirectory;
1516
using System;
1617
using System.IO;
1718
using System.Security.Cryptography;
18-
using Microsoft.IdentityModel.Clients.ActiveDirectory;
19-
using Microsoft.Azure.Common.Extensions;
2019

2120
namespace Microsoft.Azure.Common.Extensions.Authentication
2221
{

src/Common/Azure.Common.Extensions/Authentication/ServicePrincipalKeyStore.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using System;
1616
using System.Runtime.InteropServices;
1717
using System.Security;
18-
using Microsoft.Azure.Common.Extensions.Authentication;
1918
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
2019

2120
namespace Microsoft.Azure.Common.Extensions.Authentication

src/Common/Azure.Common.Extensions/Authentication/ServicePrincipalTokenProvider.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Common.Extensions.Models;
16+
using Microsoft.Azure.Common.Extensions.Properties;
17+
using Microsoft.IdentityModel.Clients.ActiveDirectory;
1518
using System;
1619
using System.Collections.Generic;
1720
using System.Security;
18-
using Microsoft.IdentityModel.Clients.ActiveDirectory;
19-
using Microsoft.Azure.Common.Extensions.Authentication;
20-
using Microsoft.Azure.Common.Extensions.Models;
21-
using Microsoft.Azure.Common.Extensions.Properties;
2221

2322
namespace Microsoft.Azure.Common.Extensions.Authentication
2423
{

src/Common/Azure.Common.Extensions/Authentication/UserTokenProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Common.Extensions.Models;
16+
using Microsoft.Azure.Common.Extensions.Properties;
17+
using Microsoft.IdentityModel.Clients.ActiveDirectory;
1518
using System;
1619
using System.Runtime.InteropServices;
1720
using System.Security;
1821
using System.Threading;
1922
using System.Windows.Forms;
20-
using Microsoft.IdentityModel.Clients.ActiveDirectory;
21-
using Microsoft.Azure.Common.Extensions.Models;
22-
using Microsoft.Azure.Common.Extensions.Properties;
2323

2424
namespace Microsoft.Azure.Common.Extensions.Authentication
2525
{

src/Common/Azure.Common.Extensions/AzureSession.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
16-
using System.Collections.Generic;
1715
using Microsoft.Azure.Common.Extensions.Factories;
1816
using Microsoft.Azure.Common.Extensions.Models;
1917
using Microsoft.Azure.Common.Extensions.Properties;
20-
using Microsoft.Azure.Common.Extensions;
21-
using Microsoft.Azure.Common.Extensions.Authentication;
18+
using System;
19+
using System.IO;
2220

2321
namespace Microsoft.Azure.Common.Extensions
2422
{
@@ -30,6 +28,13 @@ static AzureSession()
3028
AuthenticationFactory = new AuthenticationFactory();
3129
CurrentContext = new AzureContext();
3230
CurrentContext.Environment = AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud];
31+
AzureSession.OldProfileFile = "WindowsAzureProfile.xml";
32+
AzureSession.OldProfileFileBackup = "WindowsAzureProfile.xml.bak";
33+
AzureSession.ProfileDirectory = Path.Combine(
34+
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
35+
Resources.AzureDirectoryName); ;
36+
AzureSession.ProfileFile = "AzureProfile.json";
37+
AzureSession.TokenCacheFile = "TokenCache.dat";
3338
}
3439

3540
public static AzureContext CurrentContext { get; private set; }

src/Common/Azure.Common.Extensions/Common.Extensions.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@
157157
<Compile Include="Interfaces\IClientFactory.cs" />
158158
<Compile Include="Interfaces\IDataStore.cs" />
159159
<Compile Include="Interfaces\IProfileSerializer.cs" />
160-
<Compile Include="Models\UserAgentHeaderAction.cs" />
161160
<Compile Include="Models\AzureAccount.cs" />
162161
<Compile Include="Models\AzureAccount.Methods.cs" />
163162
<Compile Include="Models\AzureContext.cs" />

src/Common/Azure.Common.Extensions/Common/ProfileClient.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Common.Extensions.Authentication;
16+
using Microsoft.Azure.Common.Extensions.Factories;
17+
using Microsoft.Azure.Common.Extensions.Interfaces;
18+
using Microsoft.Azure.Common.Extensions.Models;
19+
using Microsoft.Azure.Common.Extensions.Properties;
20+
using Microsoft.Azure.Subscriptions;
21+
using Microsoft.WindowsAzure;
1522
using System;
1623
using System.Collections.Generic;
1724
using System.Diagnostics;
1825
using System.Linq;
1926
using System.Security;
2027
using System.Security.Cryptography.X509Certificates;
21-
using Microsoft.Azure.Subscriptions;
22-
using Microsoft.Azure.Common.Extensions.Factories;
23-
using Microsoft.Azure.Common.Extensions.Interfaces;
24-
using Microsoft.Azure.Common.Extensions.Models;
25-
using Microsoft.Azure.Common.Extensions.Properties;
26-
using Microsoft.Azure.Common.Extensions;
27-
using Microsoft.Azure.Common.Extensions.Authentication;
28-
using Microsoft.WindowsAzure;
2928

3029
namespace Microsoft.Azure.Common.Extensions
3130
{

src/Common/Azure.Common.Extensions/Common/ProfileData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Common.Extensions.Models;
1516
using System;
1617
using System.Collections.Generic;
1718
using System.Linq;
1819
using System.Runtime.Serialization;
1920
using System.Text;
20-
using Microsoft.Azure.Common.Extensions.Models;
2121

2222
namespace Microsoft.Azure.Common.Extensions
2323
{

src/Common/Azure.Common.Extensions/Common/PublishSettingsImporter.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Common.Extensions.Models;
16+
using Microsoft.Azure.Common.Extensions.XmlSchema;
1517
using System;
1618
using System.Collections.Generic;
1719
using System.IO;
1820
using System.Linq;
1921
using System.Security.Cryptography.X509Certificates;
2022
using System.Xml.Serialization;
21-
using Microsoft.Azure.Common.Extensions.Models;
22-
using Microsoft.Azure.Common.Extensions.XmlSchema;
23-
using Microsoft.Azure.Common.Extensions;
2423

2524
namespace Microsoft.Azure.Common.Extensions
2625
{

src/Common/Azure.Common.Extensions/Common/RequiredResourceLookup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Collections.Generic;
1615
using Microsoft.WindowsAzure.Common;
16+
using System.Collections.Generic;
1717

1818
namespace Microsoft.Azure.Common.Extensions
1919
{

src/Common/Azure.Common.Extensions/Common/Validate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Common.Extensions.Properties;
1516
using System;
1617
using System.Diagnostics.CodeAnalysis;
1718
using System.IO;
1819
using System.Linq;
1920
using System.Net;
2021
using System.Net.Sockets;
2122
using System.Runtime.InteropServices;
22-
using Microsoft.Azure.Common.Extensions.Properties;
2323

2424
namespace Microsoft.Azure.Common.Extensions
2525
{

src/Common/Azure.Common.Extensions/Factories/AuthenticationFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
16-
using System.Linq;
17-
using System.Security;
15+
using Microsoft.Azure.Common.Extensions.Authentication;
1816
using Microsoft.Azure.Common.Extensions.Models;
1917
using Microsoft.Azure.Common.Extensions.Properties;
20-
using Microsoft.Azure.Common.Extensions.Authentication;
2118
using Microsoft.WindowsAzure;
19+
using System;
20+
using System.Linq;
21+
using System.Security;
2222

2323
namespace Microsoft.Azure.Common.Extensions.Factories
2424
{

src/Common/Azure.Common.Extensions/Factories/ClientFactory.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Common.Extensions.Models;
16+
using Microsoft.Azure.Common.Extensions.Properties;
17+
using Microsoft.WindowsAzure;
18+
using Microsoft.WindowsAzure.Common;
1519
using System;
1620
using System.Collections.Generic;
1721
using System.Net;
1822
using System.Net.Http;
19-
using Microsoft.Azure.Common.Extensions.Models;
20-
using Microsoft.Azure.Common.Extensions.Properties;
21-
using Microsoft.Azure.Common.Extensions;
22-
using Microsoft.WindowsAzure.Common;
23-
using Microsoft.WindowsAzure;
23+
using System.Net.Http.Headers;
2424

2525
namespace Microsoft.Azure.Common.Extensions.Factories
2626
{
@@ -33,6 +33,7 @@ public class ClientFactory : IClientFactory
3333
public ClientFactory()
3434
{
3535
actions = new Dictionary<Type, IClientAction>();
36+
UserAgents = new List<ProductInfoHeaderValue>();
3637
}
3738

3839
public virtual TClient CreateClient<TClient>(AzureContext context, AzureEnvironment.Endpoint endpoint) where TClient : ServiceClient<TClient>
@@ -95,6 +96,11 @@ public virtual TClient CreateCustomClient<TClient>(params object[] parameters) w
9596

9697
TClient client = (TClient)constructor.Invoke(parameters);
9798

99+
foreach (ProductInfoHeaderValue userAgent in UserAgents)
100+
{
101+
client.UserAgent.Add(userAgent);
102+
}
103+
98104
return client;
99105
}
100106

@@ -164,5 +170,7 @@ public void RemoveAction(Type actionType)
164170
actions.Remove(actionType);
165171
}
166172
}
173+
174+
public List<ProductInfoHeaderValue> UserAgents { get; set; }
167175
}
168176
}

src/Common/Azure.Common.Extensions/Interfaces/IAuthenticationFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Security;
16-
using Microsoft.Azure.Common.Extensions.Models;
1715
using Microsoft.Azure.Common.Extensions.Authentication;
16+
using Microsoft.Azure.Common.Extensions.Models;
1817
using Microsoft.WindowsAzure;
18+
using System.Security;
1919

2020
namespace Microsoft.Azure.Common.Extensions
2121
{

src/Common/Azure.Common.Extensions/Interfaces/IClientFactory.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Net;
16-
using System.Net.Http;
1715
using Microsoft.Azure.Common.Extensions.Models;
1816
using Microsoft.WindowsAzure.Common;
1917
using System;
18+
using System.Collections.Generic;
19+
using System.Net;
20+
using System.Net.Http;
21+
using System.Net.Http.Headers;
2022

2123
namespace Microsoft.Azure.Common.Extensions
2224
{
@@ -35,5 +37,7 @@ public interface IClientFactory
3537
void AddAction(IClientAction action);
3638

3739
void RemoveAction(Type actionType);
40+
41+
List<ProductInfoHeaderValue> UserAgents { get; set; }
3842
}
3943
}

src/Common/Azure.Common.Extensions/Interfaces/IProfileSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Collections.Generic;
1615
using Microsoft.Azure.Common.Extensions.Models;
16+
using System.Collections.Generic;
1717

1818
namespace Microsoft.Azure.Common.Extensions.Interfaces
1919
{

src/Common/Azure.Common.Extensions/Models/AzureEnvironment.Methods.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
16-
using System.Collections.Generic;
1715
using Microsoft.Azure.Common.Extensions.Properties;
1816
using Microsoft.Azure.Common.Extensions.Utilities;
19-
using Microsoft.Azure.Common.Extensions;
17+
using System;
18+
using System.Collections.Generic;
2019

2120
namespace Microsoft.Azure.Common.Extensions.Models
2221
{

src/Common/Azure.Common.Extensions/Models/AzureProfile.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Common.Extensions.Interfaces;
16+
using Microsoft.WindowsAzure.Common.Internals;
1517
using System;
1618
using System.Collections.Generic;
1719
using System.IO;
1820
using System.Linq;
19-
using System.Security.Cryptography.X509Certificates;
20-
using Microsoft.Azure.Common.Extensions.Interfaces;
21-
using Microsoft.WindowsAzure.Common.Internals;
22-
using System.Diagnostics;
2321

2422
namespace Microsoft.Azure.Common.Extensions.Models
2523
{

src/Common/Azure.Common.Extensions/Models/AzureSubscription.Methods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Collections.Generic;
1615
using Microsoft.Azure.Common.Extensions.Utilities;
16+
using System.Collections.Generic;
1717

1818
namespace Microsoft.Azure.Common.Extensions.Models
1919
{

src/Common/Azure.Common.Extensions/Models/DiskDataStore.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Common.Extensions.Interfaces;
16+
using Microsoft.Azure.Common.Extensions.Properties;
1517
using System;
1618
using System.IO;
1719
using System.Security.Cryptography.X509Certificates;
1820
using System.Text;
19-
using Microsoft.Azure.Common.Extensions.Interfaces;
20-
using Microsoft.Azure.Common.Extensions.Properties;
21-
using Microsoft.Azure.Common.Extensions;
2221

2322
namespace Microsoft.Azure.Common.Extensions.Models
2423
{

src/Common/Azure.Common.Extensions/Models/JsonProfileSerializer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
16-
using System.Collections.Generic;
17-
using System.Linq;
1815
using Microsoft.Azure.Common.Extensions.Interfaces;
1916
using Newtonsoft.Json;
2017
using Newtonsoft.Json.Linq;
18+
using System;
19+
using System.Collections.Generic;
20+
using System.Linq;
2121

2222
namespace Microsoft.Azure.Common.Extensions.Models
2323
{

0 commit comments

Comments
 (0)