public static void DeleteManagedIdentity(ManagedServiceIdentityClient identityClient, string rgname, string identityName) { if (!IsTestTenant) { identityClient.UserAssignedIdentities.Delete(rgname, identityName); } }
protected void InitializeClients(MockContext context) { if (!m_initialized) { lock (m_lock) { if (!m_initialized) { _resourceManagementClient = EventHubManagementHelper.GetResourceManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); _EventHubManagementClient = EventHubManagementHelper.GetEventHubManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); _KeyVaultManagementClient = EventHubManagementHelper.GetKeyVaultManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); _NetworkManagementClient = EventHubManagementHelper.GetNetworkManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); _IdentityManagementClient = EventHubManagementHelper.GetIdentityManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); } } } }
/// <summary> /// Ctor /// </summary> /// <param name="commonData"></param> /// <param name="context"></param> public HDInsightManagementHelper(CommonTestFixture commonData, HDInsightMockContext context) { resourceManagementClient = context.GetServiceClient <ResourceManagementClient>(); storageManagementClient = context.GetServiceClient <StorageManagementClient>(); identityManagementClient = context.GetServiceClient <ManagedServiceIdentityClient>(); authorizationManagementClient = context.GetServiceClient <AuthorizationManagementClient>(); keyVaultManagementClient = context.GetServiceClient <KeyVaultManagementClient>(); keyVaultClient = GetKeyVaultClient(); this.commonData = commonData; }
public DeploymentManagerClientHelper(TestBase testBase, MockContext context, RecordedDelegatingHandler handler) { _testBase = testBase; _context = context; resourceManagementClient = DeploymentManagerTestUtilities.GetResourceManagementClient(context, handler); storageManagementClient = DeploymentManagerTestUtilities.GetStorageManagementClient(context, handler); managedServiceIdentityClient = DeploymentManagerTestUtilities.GetManagedServiceIdentityClient(context, handler); authorizationClient = DeploymentManagerTestUtilities.GetAuthorizationManagementClient(context, handler); }
public static ManagedServiceIdentityClient GetIdentityManagementClient(MockContext context, RecordedDelegatingHandler handler) { if (handler != null) { handler.IsPassThrough = true; ManagedServiceIdentityClient identityManagementClient = context.GetServiceClient <ManagedServiceIdentityClient>(handlers: handler); return(identityManagementClient); } return(null); }
public static ManagedServiceIdentityClient GetManagedIdentityClient(MockContext context, RecordedDelegatingHandler handler) { if (IsTestTenant) { return(null); } else { handler.IsPassThrough = true; ManagedServiceIdentityClient managedIdentityClient = context.GetServiceClient <ManagedServiceIdentityClient>(handlers: handler); return(managedIdentityClient); } }
public static Identity CreateManagedIdentity(ManagedServiceIdentityClient identityClient, string rgname, string location) { var identityName = TestUtilities.GenerateName("uami"); if (!IsTestTenant) { return(identityClient.UserAssignedIdentities.CreateOrUpdate(rgname, identityName, new Identity { Location = location })); } return(null); }
protected MockContext StartMockContextAndInitializeClients(Type typeName, // Automatically populates the methodName parameter with the calling method, which // gets used to generate recorder file names. [System.Runtime.CompilerServices.CallerMemberName] string methodName = "") { MockContext context = MockContext.Start(typeName, methodName); var handler1 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var handler2 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var handler3 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var handler4 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var handler5 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; // Create clients VideoAnalyzerClient = VideoAnalyzerManagementTestUtilities.GetVideoAnalyzerManagementClient(context, handler1); ResourceClient = VideoAnalyzerManagementTestUtilities.GetResourceManagementClient(context, handler2); StorageClient = VideoAnalyzerManagementTestUtilities.GetStorageManagementClient(context, handler3); IdentityManagementClient = VideoAnalyzerManagementTestUtilities.GetManagedIdentityClient(context, handler4); authorizationManagementClient = VideoAnalyzerManagementTestUtilities.GetAuthorizationManagementClient(context, handler5); Location = VideoAnalyzerManagementTestUtilities.TryGetLocation(ResourceClient, VideoAnalyzerManagementTestUtilities.DefaultLocation); ResourceGroup = VideoAnalyzerManagementTestUtilities.CreateResourceGroup(ResourceClient, Location); // Create storage account StorageAccount = VideoAnalyzerManagementTestUtilities.CreateStorageAccount(StorageClient, ResourceGroup, Location); ManagedIdentity = VideoAnalyzerManagementTestUtilities.CreateManagedIdentity(IdentityManagementClient, ResourceGroup, Location); VideoAnalyzerManagementTestUtilities.AddRoleAssignment(authorizationManagementClient, StorageAccount.Id, "Storage Blob Data Contributor", TestUtilities.GenerateGuid().ToString(), ManagedIdentity.PrincipalId.ToString()); VideoAnalyzerManagementTestUtilities.AddRoleAssignment(authorizationManagementClient, StorageAccount.Id, "Reader", TestUtilities.GenerateGuid().ToString(), ManagedIdentity.PrincipalId.ToString()); return(context); }
private void SetupManagementClients(MockContext context) { var resourceManagerResourceManagementClient = GetResourceManagerResourceManagementClient(context); NetworkManagementClient = GetNetworkManagementClient(context); ComputeManagementClient = GetComputeManagementClient(context); ContainerInstanceManagementClient = GetContainerInstanceManagementClient(context); StorageManagementClient = GetStorageManagementClient(context); RedisManagementClient = GetRedisManagementClient(context); OperationalInsightsManagementClient = GetOperationalInsightsManagementClient(context); ManagedServiceIdentityClient = GetManagedServiceIdentityClient(context); _helper.SetupManagementClients( resourceManagerResourceManagementClient, NetworkManagementClient, ComputeManagementClient, ContainerInstanceManagementClient, StorageManagementClient, RedisManagementClient, OperationalInsightsManagementClient, ManagedServiceIdentityClient); }