Skip to content

Clu #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 18, 2015
Merged

Clu #261

Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -12,9 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using System;
using Microsoft.Azure.Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest;
using System;
using Microsoft.Azure.Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.Runtime.InteropServices;
using Microsoft.Rest.Azure.Authentication;
using System.Management.Automation;
using Commands.Common.Authentication.Properties;
using Microsoft.Azure.Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest;
using Microsoft.Rest.Azure.Authentication;
using Commands.Common.Authentication.Properties;
using Microsoft.Azure.Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication.Factories
{
Expand Down
2 changes: 1 addition & 1 deletion src/CLU/Commands.Common.Authentication/ClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Rest;
using System;
Expand All @@ -23,6 +22,7 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
using Microsoft.Azure.Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication.Factories
{
Expand Down
2 changes: 1 addition & 1 deletion src/CLU/Commands.Common.Authentication/JsonUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Azure.Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using System;
using System.Collections.Generic;
using Microsoft.Azure.Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication.Models
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using Microsoft.Rest;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Azure.Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication.Models
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Microsoft.Azure.Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication.Models
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/CLU/Commands.Common.Authentication/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<value>The environment name '{0}' is not found.</value>
</data>
<data name="ExpiredRefreshToken" xml:space="preserve">
<value>Your Microsoft Azure credential in the Windows PowerShell session has expired. Please log in again. In PowerShell, execute Login-AzureRMAccount for Azure Resource Manager cmdlets or Add-AzureAccount for service management cmdlets.</value>
<value>Your Microsoft Azure credential has expired. Please log in again.</value>
</data>
<data name="FilePathIsNotValid" xml:space="preserve">
<value>File path is not valid</value>
Expand Down Expand Up @@ -190,7 +190,7 @@
<value>Removing public environment is not supported.</value>
</data>
<data name="ServiceKeyNotFound" xml:space="preserve">
<value>Unable to retrieve service key for ServicePrincipal account {0}. Please log in again to supply the credentials for this service principal. In PowerShell, execute Login-AzureRMAccount for Azure Resource Manager cmdlets or Add-AzureAccount for service management cmdlets.</value>
<value>Unable to retrieve service key for ServicePrincipal account {0}. Please add your account again to supply the credentials for this service principal.</value>
</data>
<data name="ServiceNameExists" xml:space="preserve">
<value>The provided service name {0} already exists, please pick another name</value>
Expand Down Expand Up @@ -256,7 +256,7 @@
<value>Multiple tokens were found for this user. Please clear your token cache using, Clear-AzureProfile and try this command again.</value>
</data>
<data name="AdalUserInteractionRequired" xml:space="preserve">
<value>User Interaction is required to authenticate this user. Please authenticate using the log in dialog. In PowerShell, execute Login-AzureRMAccount for Azure Resource Manager cmdlets or Add-AzureAccount for service management cmdlets.</value>
<value>User Interaction is required to authenticate this user. Please authenticate using device authentication, by adding an account without providing credentials on the command line.</value>
</data>
<data name="TenantNotFound" xml:space="preserve">
<value>No tenant was found for this subscription. Please execute Clear-AzureProfile and then execute Add-AzureAccount.</value>
Expand All @@ -280,19 +280,19 @@
<value>[Common.Authentication]: Authenticating for account {0} with single tenant {1}</value>
</data>
<data name="ArmAccountNotFound" xml:space="preserve">
<value>No account found in the context. Please login using Login-AzureRMAccount.</value>
<value>No account found in the context. Please add your account again.</value>
</data>
<data name="ArmUserInteractionRequired" xml:space="preserve">
<value>User Interaction is required to authenticate this user. Please execute Login-AzureRMAccount without parameters and enter your credentials.</value>
<value>User Interaction is required to authenticate this user. Please login using device authentication by adding your account without providing credentials on the command line.</value>
</data>
<data name="InvalidArmContext" xml:space="preserve">
<value>Your Azure credentials have not been set up or have expired, please run Login-AzureRMAccount to set up your Azure credentials.</value>
<value>Your Azure credentials have not been set up or have expired, please add an account to set up your Azure credentials.</value>
</data>
<data name="NoSubscriptionInContext" xml:space="preserve">
<value>No subscription found in the context. Please ensure that the credentials you provided are authorized to access an Azure subscription, then run Login-AzureRMAccount to login.</value>
<value>No subscription found in the context. Please ensure that the credentials you provided are authorized to access an Azure subscription, then radd your account again.</value>
</data>
<data name="NoTenantInContext" xml:space="preserve">
<value>No tenant found in the context. Please ensure that the credentials you provided are authorized to access an Azure subscription, then run Login-AzureRMAccount to login.</value>
<value>No tenant found in the context. Please ensure that the credentials you provided are authorized to access an Azure subscription, then add your account again.</value>
</data>
<data name="UnsupportedCredentialType" xml:space="preserve">
<value>Certificate authentication is not supported for account type {0}.</value>
Expand Down
2 changes: 1 addition & 1 deletion src/CLU/Commands.Common.Authentication/Validate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using System;
using System.IO;
using System.Linq;
using Microsoft.Azure.Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication
{
Expand Down
16 changes: 15 additions & 1 deletion src/CLU/Commands.Common.ScenarioTest/ExampleScriptRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public ExampleScriptRunner(Random generator, string sessionId)
{
_generator = generator;
_sessionId = sessionId;
EnvironmentVariables = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}

public IClientFactory ClientFactory
Expand All @@ -68,6 +69,8 @@ public TestContext TestContext
set { _context = value; }
}

public IDictionary<string, string> EnvironmentVariables { get; private set; }

public string ScriptOutput { get; protected set; }

public string RunScript(string testName)
Expand Down Expand Up @@ -105,6 +108,12 @@ public string RunScript(string testName)
{
helper.TrySetupScriptEnvironment(_context, _clientFactory, process.EnvironmentVariables);
}

foreach (var environmentVar in EnvironmentVariables.Keys)
{
process.EnvironmentVariables.Add(environmentVar, EnvironmentVariables[environmentVar]);
}

int statusCode = process.StartAndWaitForExit();
Assert.Equal(0, statusCode);
return process.Output;
Expand Down Expand Up @@ -136,7 +145,12 @@ public void DeployTemplate(string deploymentTemplatePath, string resourceGroupNa

public string CreateRandomName()
{
return "clutst" + _generator.Next(10000, 99999);
return GenerateName("clutst");
}

public string GenerateName(string prefix)
{
return $"{prefix}{_generator.Next(10000, 99999)}";
}

private void EnsureClient()
Expand Down
24 changes: 24 additions & 0 deletions src/CLU/Commands.Common.ScenarioTest/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Diagnostics;
using Microsoft.Extensions.Logging;

namespace Microsoft.Azure.Commands.Common.ScenarioTest
{
Expand All @@ -26,17 +28,39 @@ static Logger()

private Logger()
{
var factory = new LoggerFactory();
_consoleLogger = factory.CreateLogger<Logger>();
factory.AddConsole();
}

private ILogger _consoleLogger;

public void WriteMessage(string message)
{
Trace.WriteLine(message);
LogMessageInChunks(message);
}

/// <summary>
/// The dnx logger fails with large messages
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
private void LogMessageInChunks(string message, int chunkSize = 5000)
{
if (!string.IsNullOrWhiteSpace(message))
{
for (int i = 0; i < message.Length; i += Math.Min(chunkSize, message.Length - i))
{
_consoleLogger.LogInformation(message.Substring(i, Math.Min(chunkSize, message.Length - i)));
}
}
}

public void WriteError(string message)
{
Trace.WriteLine($"Error: {message}");
LogMessageInChunks($"Error: {message}");
}
}
}
1 change: 1 addition & 0 deletions src/CLU/Commands.Common.ScenarioTest/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"Commands.ScenarioTests.ResourceManager.Common": "",
"Microsoft.Azure.Commands.Profile": "",
"Microsoft.Azure.Management.Resources": "3.3.0-preview",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.212041202-alpha",
"Microsoft.Rest.ClientRuntime": "1.8.0",
"Microsoft.Rest.ClientRuntime.Azure": "2.5.1",
Expand Down
4 changes: 2 additions & 2 deletions src/CLU/Commands.Common/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading