public void TableIngressEgressACLs() { CloudTableClient tableClient = GenerateCloudTableClient(); CloudTable tbl = tableClient.GetTableReference(GenerateRandomTableName()); tbl.CreateIfNotExists(); try { TablePermissions perms = new TablePermissions(); // Add a policy, check setting and getting. perms.SharedAccessPolicies.Add(Guid.NewGuid().ToString(), new SharedAccessTablePolicy { Permissions = SharedAccessTablePermissions.Query, SharedAccessStartTime = DateTimeOffset.Now - TimeSpan.FromHours(1), SharedAccessExpiryTime = DateTimeOffset.Now + TimeSpan.FromHours(1) }); TestHelper.ValidateIngressEgress(Selectors.IfUrlContains(tbl.Uri.ToString()), () => { OperationContext opContext = new OperationContext(); tbl.EndSetPermissions(tbl.BeginSetPermissions(perms, new TableRequestOptions() { RetryPolicy = new RetryPolicies.NoRetry() }, opContext, null, null)); return(opContext.LastResult); }); TestHelper.ValidateIngressEgress(Selectors.IfUrlContains(tbl.Uri.ToString()), () => { OperationContext opContext = new OperationContext(); tbl.EndGetPermissions(tbl.BeginGetPermissions(new TableRequestOptions() { RetryPolicy = new RetryPolicies.NoRetry() }, opContext, null, null)); return(opContext.LastResult); }); } finally { tbl.DeleteIfExists(); } }
public void TableSetACLCancellation() { CloudTableClient tableClient = GenerateCloudTableClient(); CloudTable tbl = tableClient.GetTableReference(GenerateRandomTableName()); TablePermissions perms = new TablePermissions(); // Add a policy, check setting and getting. perms.SharedAccessPolicies.Add(Guid.NewGuid().ToString(), new SharedAccessTablePolicy { Permissions = SharedAccessTablePermissions.Query, SharedAccessStartTime = DateTimeOffset.Now - TimeSpan.FromHours(1), SharedAccessExpiryTime = DateTimeOffset.Now + TimeSpan.FromHours(1) }); TestHelper.ExecuteAPMMethodWithCancellation(4000, new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, XStoreSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName)) }, (options, opContext, callback, state) => tbl.BeginSetPermissions(perms, (TableRequestOptions)options, opContext, callback, state), tbl.EndSetPermissions); }