diff --git a/src/Accounts/Accounts/ChangeLog.md b/src/Accounts/Accounts/ChangeLog.md
index 106216c61a75..ec51c9c65751 100644
--- a/src/Accounts/Accounts/ChangeLog.md
+++ b/src/Accounts/Accounts/ChangeLog.md
@@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
+* Updated Azure PowerShell survey URL in `Resolve-AzError` [#11507]
## Version 1.7.4
* Fixed `Get-AzTenant`/`Get-AzDefault`/`Set-AzDefault` throw NullReferenceException when not login [#10292]
diff --git a/src/Accounts/Accounts/Common/AzureProfileConstants.cs b/src/Accounts/Accounts/Common/AzureProfileConstants.cs
index 40071b637792..4db9a9032f14 100644
--- a/src/Accounts/Accounts/Common/AzureProfileConstants.cs
+++ b/src/Accounts/Accounts/Common/AzureProfileConstants.cs
@@ -22,7 +22,9 @@ public static class AzureProfileConstants
public const string AzureSurveyUrl = "https://aka.ms/azpssurvey?Q_CHL=FEEDBACK";
- public static readonly string AzurePowerShellFeedbackMessage = string.Format(Resources.AzurePowerShellFeedback, AzureProfileConstants.AzureSurveyUrl);
+ public const string AzureSurveyUrlForError = "https://aka.ms/azpssurvey?Q_CHL=ERROR";
+
+ public static readonly string AzurePowerShellFeedbackMessage = string.Format(Resources.AzurePowerShellFeedback, AzureProfileConstants.AzureSurveyUrlForError);
public static readonly string AzurePowerShellFeedbackQuestion = string.Format(Resources.SendFeedbackOpenLinkAutomatically, AzureProfileConstants.AzureSurveyUrl);
diff --git a/src/Attestation/Attestation.Test/ScenarioTests/AttstationPolicyTests.ps1 b/src/Attestation/Attestation.Test/ScenarioTests/AttstationPolicyTests.ps1
index b37b50edb03c..7512f0b42e01 100644
--- a/src/Attestation/Attestation.Test/ScenarioTests/AttstationPolicyTests.ps1
+++ b/src/Attestation/Attestation.Test/ScenarioTests/AttstationPolicyTests.ps1
@@ -37,7 +37,11 @@ function Test-GetAttestationPolicy
Assert-NotNull $attestationCreated.Status
$getPolicy = Get-AzAttestationPolicy -Name $attestationProviderName -ResourceGroupName $rgName.ResourceGroupName -Tee $teeType
- Assert-NotNull $getPolicy
+ Assert-NotNull $getPolicy.Jwt
+ Assert-NotNull $getPolicy.Text
+ Assert-AreEqual "none" $getPolicy.Algorithm
+ Assert-True { $getPolicy.JwtLength -gt 0 }
+ Assert-True { $getPolicy.TextLength -gt 0 }
}
finally
@@ -93,7 +97,8 @@ function Test-SetAttestationPolicy
$attestationProviderName = getAssetName
$location = "East US"
$teeType = "SgxEnclave"
- $policyDocument = "eyJhbGciOiJub25lIn0.eyJBdHRlc3RhdGlvblBvbGljeSI6ICJ7XHJcbiAgICBcIiR2ZXJzaW9uXCI6IDEsXHJcbiAgICBcIiRhbGxvdy1kZWJ1Z2dhYmxlXCIgOiB0cnVlLFxyXG4gICAgXCIkY2xhaW1zXCI6W1xyXG4gICAgICAgIFwiaXMtZGVidWdnYWJsZVwiICxcclxuICAgICAgICBcInNneC1tcnNpZ25lclwiLFxyXG4gICAgICAgIFwic2d4LW1yZW5jbGF2ZVwiLFxyXG4gICAgICAgIFwicHJvZHVjdC1pZFwiLFxyXG4gICAgICAgIFwic3ZuXCIsXHJcbiAgICAgICAgXCJ0ZWVcIixcclxuICAgICAgICBcIk5vdERlYnVnZ2FibGVcIlxyXG4gICAgXSxcclxuICAgIFwiTm90RGVidWdnYWJsZVwiOiB7XCJ5ZXNcIjp7XCIkaXMtZGVidWdnYWJsZVwiOnRydWUsIFwiJG1hbmRhdG9yeVwiOnRydWUsIFwiJHZpc2libGVcIjpmYWxzZX19LFxyXG4gICAgXCJpcy1kZWJ1Z2dhYmxlXCIgOiBcIiRpcy1kZWJ1Z2dhYmxlXCIsXHJcbiAgICBcInNneC1tcnNpZ25lclwiIDogXCIkc2d4LW1yc2lnbmVyXCIsXHJcbiAgICBcInNneC1tcmVuY2xhdmVcIiA6IFwiJHNneC1tcmVuY2xhdmVcIixcclxuICAgIFwicHJvZHVjdC1pZFwiIDogXCIkcHJvZHVjdC1pZFwiLFxyXG4gICAgXCJzdm5cIiA6IFwiJHN2blwiLFxyXG4gICAgXCJ0ZWVcIiA6IFwiJHRlZVwiXHJcbn0ifQ."
+ $policyJwt = "eyJhbGciOiJub25lIn0.eyJBdHRlc3RhdGlvblBvbGljeSI6ICJ7XHJcbiAgICBcIiR2ZXJzaW9uXCI6IDEsXHJcbiAgICBcIiRhbGxvdy1kZWJ1Z2dhYmxlXCIgOiB0cnVlLFxyXG4gICAgXCIkY2xhaW1zXCI6W1xyXG4gICAgICAgIFwiaXMtZGVidWdnYWJsZVwiICxcclxuICAgICAgICBcInNneC1tcnNpZ25lclwiLFxyXG4gICAgICAgIFwic2d4LW1yZW5jbGF2ZVwiLFxyXG4gICAgICAgIFwicHJvZHVjdC1pZFwiLFxyXG4gICAgICAgIFwic3ZuXCIsXHJcbiAgICAgICAgXCJ0ZWVcIixcclxuICAgICAgICBcIk5vdERlYnVnZ2FibGVcIlxyXG4gICAgXSxcclxuICAgIFwiTm90RGVidWdnYWJsZVwiOiB7XCJ5ZXNcIjp7XCIkaXMtZGVidWdnYWJsZVwiOnRydWUsIFwiJG1hbmRhdG9yeVwiOnRydWUsIFwiJHZpc2libGVcIjpmYWxzZX19LFxyXG4gICAgXCJpcy1kZWJ1Z2dhYmxlXCIgOiBcIiRpcy1kZWJ1Z2dhYmxlXCIsXHJcbiAgICBcInNneC1tcnNpZ25lclwiIDogXCIkc2d4LW1yc2lnbmVyXCIsXHJcbiAgICBcInNneC1tcmVuY2xhdmVcIiA6IFwiJHNneC1tcmVuY2xhdmVcIixcclxuICAgIFwicHJvZHVjdC1pZFwiIDogXCIkcHJvZHVjdC1pZFwiLFxyXG4gICAgXCJzdm5cIiA6IFwiJHN2blwiLFxyXG4gICAgXCJ0ZWVcIiA6IFwiJHRlZVwiXHJcbn0ifQ."
+ $policyText = 'version= 1.0;authorizationrules{c:[type=="$is-debuggable"] => permit();};issuancerules{c:[type=="$is-debuggable"] => issue(type="is-debuggable", value=c.value);c:[type=="$sgx-mrsigner"] => issue(type="sgx-mrsigner", value=c.value);c:[type=="$sgx-mrenclave"] => issue(type="sgx-mrenclave", value=c.value);c:[type=="$product-id"] => issue(type="product-id", value=c.value);c:[type=="$svn"] => issue(type="svn", value=c.value);c:[type=="$tee"] => issue(type="tee", value=c.value);c:[type=="$tee-future"] => issue(type="tee-future", value=c.value);};'
# Prevent this script from inadvertantly running in Record or Playback modes
try
@@ -121,7 +126,10 @@ function Test-SetAttestationPolicy
Assert-NotNull $attestationCreated.Status
# NOTE: Set-AzAttestionPolicy does not work in recording/playback mode because the recorded JWT token expires and then fails validation
- $setPolicyResponse = Set-AzAttestationPolicy -Name $attestationProviderName -ResourceGroupName $rgName.ResourceGroupName -Tee $teeType -Policy $policyDocument -PassThru
+ $setPolicyResponse = Set-AzAttestationPolicy -Name $attestationProviderName -ResourceGroupName $rgName.ResourceGroupName -Tee $teeType -Policy $policyJwt -PolicyFormat Jwt -PassThru
+ Assert-AreEqual $setPolicyResponse $true
+
+ $setPolicyResponse = Set-AzAttestationPolicy -Name $attestationProviderName -ResourceGroupName $rgName.ResourceGroupName -Tee $teeType -Policy $policyText -PassThru
Assert-AreEqual $setPolicyResponse $true
}
diff --git a/src/Attestation/Attestation/ChangeLog.md b/src/Attestation/Attestation/ChangeLog.md
index 517f736ba4db..081eff30acb5 100644
--- a/src/Attestation/Attestation/ChangeLog.md
+++ b/src/Attestation/Attestation/ChangeLog.md
@@ -20,6 +20,7 @@
## Upcoming Release
+* Added text based policy support to policy cmdlets
## Version 0.1.6
* Improved error messages for server response codes 400 and 401
diff --git a/src/Attestation/Attestation/Commands/GetAzureAttestationPolicy.cs b/src/Attestation/Attestation/Commands/GetAzureAttestationPolicy.cs
index 7108ee50a02e..6bb02ba0c7c1 100644
--- a/src/Attestation/Attestation/Commands/GetAzureAttestationPolicy.cs
+++ b/src/Attestation/Attestation/Commands/GetAzureAttestationPolicy.cs
@@ -23,7 +23,7 @@ namespace Microsoft.Azure.Commands.Attestation
/// Get AttestationPolicy.
///
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "AttestationPolicy", SupportsShouldProcess = true)]
- [OutputType(typeof(String))]
+ [OutputType(typeof(PSPolicy))]
public class GetAzureAttestationPolicy : AttestationDataServiceCmdletBase
{
#region Input Parameter Definitions
@@ -79,7 +79,7 @@ public class GetAzureAttestationPolicy : AttestationDataServiceCmdletBase
public override void ExecuteCmdlet()
{
String policy = AttestationDataPlaneClient.GetPolicy(Name, ResourceGroupName, ResourceId, Tee);
- WriteObject(policy);
+ WriteObject(new PSPolicy(policy));
}
}
}
diff --git a/src/Attestation/Attestation/Commands/SetAzureAttestationPolicy.cs b/src/Attestation/Attestation/Commands/SetAzureAttestationPolicy.cs
index dee7587b7311..9a11825049c4 100644
--- a/src/Attestation/Attestation/Commands/SetAzureAttestationPolicy.cs
+++ b/src/Attestation/Attestation/Commands/SetAzureAttestationPolicy.cs
@@ -68,22 +68,33 @@ public class SetAzureAttestationPolicy : AttestationDataServiceCmdletBase
///
[Parameter(Mandatory = true,
HelpMessage =
- "Specifies a type of Trusted Execution Environment. We support four types of environment: SgxEnclave, OpenEnclave, CyResComponent and VBSEnclave."
+ "Specifies a type of Trusted Execution Environment. Four types of environment are supported: SgxEnclave, OpenEnclave, CyResComponent and VBSEnclave."
)]
[PSArgumentCompleter("SgxEnclave", "OpenEnclave", "CyResComponent", "VBSEnclave")]
[ValidateNotNullOrEmpty]
public string Tee { get; set; }
///
- /// JSON Web Token
+ /// Policy document
///
[Parameter(Mandatory = true,
HelpMessage =
- "Specifies the JSON Web Token describing the policy document to set."
+ "Specifies the policy document to set. The policy format can be either Text or JSON Web Token (JWT)."
)]
[ValidateNotNullOrEmpty]
public string Policy { get; set; }
+ ///
+ /// Format of the policy document
+ ///
+ [Parameter(Mandatory = false,
+ HelpMessage =
+ "Specifies the format for the policy, either Text or JWT (JSON Web Token). The default policy format is Text."
+ )]
+ [PSArgumentCompleter(TextPolicyFormat, JwtPolicyFormat)]
+ [PSDefaultValue(Value = TextPolicyFormat)]
+ public string PolicyFormat { get; set; }
+
[Parameter(Mandatory = false,
HelpMessage = "This Cmdlet does not return an object by default. If this switch is specified, it returns true if successful.")]
public SwitchParameter PassThru { get; set; }
@@ -94,12 +105,15 @@ public override void ExecuteCmdlet()
{
if (ShouldProcess(Name, "SetAttestationPolicy"))
{
- AttestationDataPlaneClient.SetPolicy(Name, ResourceGroupName, ResourceId, Tee, Policy);
+ AttestationDataPlaneClient.SetPolicy(Name, ResourceGroupName, ResourceId, Tee, Policy, PolicyFormat);
if (PassThru)
{
WriteObject(true);
}
}
}
+
+ internal const string JwtPolicyFormat = "JWT";
+ internal const string TextPolicyFormat = "Text";
}
}
\ No newline at end of file
diff --git a/src/Attestation/Attestation/Models/AttestationDataServiceClient.cs b/src/Attestation/Attestation/Models/AttestationDataServiceClient.cs
index 130283b88d8b..dcf53888ab51 100644
--- a/src/Attestation/Attestation/Models/AttestationDataServiceClient.cs
+++ b/src/Attestation/Attestation/Models/AttestationDataServiceClient.cs
@@ -48,26 +48,29 @@ public AttestationDataServiceClient(IAuthenticationFactory authFactory, IAzureCo
_attestationControlPlaneClient = AzureSession.Instance.ClientFactory.CreateArmClient(context, AzureEnvironment.Endpoint.ResourceManager);
}
- public void SetPolicy(string name, string resourceGroupName, string resourceId, string tee, string policyJwt)
+ public void SetPolicy(string name, string resourceGroupName, string resourceId, string tee, string userSpecifiedPolicy, string policyFormat)
{
ValidateCommonParameters(ref name, ref resourceGroupName, resourceId);
if (string.IsNullOrEmpty(tee))
throw new ArgumentNullException(nameof(tee));
- if (string.IsNullOrEmpty(policyJwt))
- throw new ArgumentNullException(nameof(policyJwt));
+ if (string.IsNullOrEmpty(userSpecifiedPolicy))
+ throw new ArgumentNullException(nameof(userSpecifiedPolicy));
- // Step #1 - Ask service to prepare to set policy
+ // Step #1 - Convert text policy to JWT if necessary
+ var processedPolicy = GenerateJwtPolicyIfNeeded(policyFormat, userSpecifiedPolicy);
+
+ // Step #2 - Ask service to prepare to set policy
AzureOperationResponse