public void CreateDeleteServicePrincipalTest() { using (UndoContext context = UndoContext.Current) { context.Start(); //Arrange var client = new GraphTestBase(); ServicePrincipal sp = null; //Test var passwordCredential = client.CreatePasswordCredential(); var application = client.CreateApplication(passwordCredential); try { sp = client.CreateServicePrincipal(application.AppId); client.DeleteServicePrincipal(sp.ObjectId); } finally { client.DeleteApplication(application.ObjectId); } //verify the user has been deleted. Assert.Throws(typeof(CloudException), () => { client.SearchServicePrincipal(sp.ObjectId); }); } }
public void CreateDeleteApplicationTest() { using (UndoContext context = UndoContext.Current) { context.Start(); //Arrange var client = new GraphTestBase(); //Test var passwordCredential = client.CreatePasswordCredential(); var keyCredential = client.CreateKeyCredential(); var application = client.CreateApplication(passwordCredential, keyCredential); try { var newPasswordCredential = client.CreatePasswordCredential(); client.UpdateApplication(application.ObjectId, newPasswordCredential); } finally { client.DeleteApplication(application.ObjectId); } //verify the app has been deleted. Assert.Throws(typeof(CloudException), () => { client.GetpplicationByAppObjectId(application.ObjectId); }); } }
public void GetListApplicationTest() { using (UndoContext context = UndoContext.Current) { context.Start(); //Arrange var client = new GraphTestBase(); //Test var passwordCredential = client.CreatePasswordCredential(); var keyCredential = client.CreateKeyCredential(); var application = client.CreateApplication(passwordCredential, keyCredential); try { // Get Application by applicationObjectId var fetchedApplicationByAppObjectId = client.GetpplicationByAppObjectId(application.ObjectId); Assert.NotNull(fetchedApplicationByAppObjectId); Assert.Equal(application.ObjectId, fetchedApplicationByAppObjectId.ObjectId); //Get Application by applicationId var fetchedApplicationsByAppId = client.ListApplicationsByFilters(new ApplicationFilterParameters { AppId = Guid.Parse(application.AppId) }); Assert.NotNull(fetchedApplicationsByAppId); Assert.Equal(1, fetchedApplicationsByAppId.Count); Assert.Equal(application.AppId, fetchedApplicationsByAppId.First().AppId); // Get Application by identifierUri var fetchedApplicationsByIdentifierUri = client.ListApplicationsByFilters(new ApplicationFilterParameters { IdentifierUri = application.IdentifierUris.First() }); Assert.NotNull(fetchedApplicationsByIdentifierUri); Assert.Equal(1, fetchedApplicationsByIdentifierUri.Count); Assert.True(fetchedApplicationsByIdentifierUri.First().IdentifierUris.Contains(application.IdentifierUris.First())); // Get Application by startswith name var fetchedApplicationsByDisplayNamePrefix = client.ListApplicationsByFilters(new ApplicationFilterParameters { DisplayNameStartsWith = "adApplication" }); Assert.NotNull(fetchedApplicationsByDisplayNamePrefix); Assert.True(fetchedApplicationsByDisplayNamePrefix.Count >= 1); Assert.True(fetchedApplicationsByDisplayNamePrefix.All(a => a.DisplayName.StartsWith("adApplication"))); // Get Application by startswith name var fetchedApplicationsByDisplayNameExact = client.ListApplicationsByFilters(new ApplicationFilterParameters { DisplayNameStartsWith = application.DisplayName }); Assert.NotNull(fetchedApplicationsByDisplayNameExact); Assert.Equal(1, fetchedApplicationsByDisplayNameExact.Count); Assert.True(fetchedApplicationsByDisplayNameExact.First().DisplayName.StartsWith(application.DisplayName)); } finally { client.DeleteApplication(application.ObjectId); } Assert.Throws(typeof(CloudException), () => { client.GetpplicationByAppObjectId(application.ObjectId); }); } }
public void CreateDeleteApplicationTest() { using (UndoContext context = UndoContext.Current) { context.Start(); //Arrange var client = new GraphTestBase(); //Test var passwordCredential = client.CreatePasswordCredential(); var keyCredential = client.CreateKeyCredential(); var application = client.CreateApplication(passwordCredential, keyCredential); try { var newPasswordCredential = client.CreatePasswordCredential(); client.UpdateApplication(application.ObjectId, newPasswordCredential); } finally { client.DeleteApplication(application.ObjectId); } //verify the app has been deleted. Assert.Throws(typeof(CloudException), () => { client.GetpplicationByAppObjectId(application.ObjectId); }); } }
public void CreateDeleteServicePrincipalTest() { using (UndoContext context = UndoContext.Current) { context.Start(); //Arrange var client = new GraphTestBase(); ServicePrincipal sp = null; //Test var passwordCredential = client.CreatePasswordCredential(); var application = client.CreateApplication(passwordCredential); try { sp = client.CreateServicePrincipal(application.AppId); client.DeleteServicePrincipal(sp.ObjectId); } finally { client.DeleteApplication(application.ObjectId); } //verify the user has been deleted. Assert.Throws(typeof(CloudException), () => { client.SearchServicePrincipal(sp.ObjectId); }); } }
public void GetListApplicationTest() { using (UndoContext context = UndoContext.Current) { context.Start(); //Arrange var client = new GraphTestBase(); //Test var passwordCredential = client.CreatePasswordCredential(); var keyCredential = client.CreateKeyCredential(); var application = client.CreateApplication(passwordCredential, keyCredential); try { // Get Application by applicationObjectId var fetchedApplicationByAppObjectId = client.GetpplicationByAppObjectId(application.ObjectId); Assert.NotNull(fetchedApplicationByAppObjectId); Assert.Equal(application.ObjectId, fetchedApplicationByAppObjectId.ObjectId); //Get Application by applicationId var fetchedApplicationsByAppId = client.ListApplicationsByFilters(new ApplicationFilterParameters { AppId = Guid.Parse(application.AppId) }); Assert.NotNull(fetchedApplicationsByAppId); Assert.Equal(1, fetchedApplicationsByAppId.Count); Assert.Equal(application.AppId, fetchedApplicationsByAppId.First().AppId); // Get Application by identifierUri var fetchedApplicationsByIdentifierUri = client.ListApplicationsByFilters(new ApplicationFilterParameters { IdentifierUri = application.IdentifierUris.First() }); Assert.NotNull(fetchedApplicationsByIdentifierUri); Assert.Equal(1, fetchedApplicationsByIdentifierUri.Count); Assert.True(fetchedApplicationsByIdentifierUri.First().IdentifierUris.Contains(application.IdentifierUris.First())); // Get Application by startswith name var fetchedApplicationsByDisplayNamePrefix = client.ListApplicationsByFilters(new ApplicationFilterParameters { DisplayNameStartsWith = "adApplication" }); Assert.NotNull(fetchedApplicationsByDisplayNamePrefix); Assert.True(fetchedApplicationsByDisplayNamePrefix.Count >= 1); Assert.True(fetchedApplicationsByDisplayNamePrefix.All(a => a.DisplayName.StartsWith("adApplication"))); // Get Application by startswith name var fetchedApplicationsByDisplayNameExact = client.ListApplicationsByFilters(new ApplicationFilterParameters { DisplayNameStartsWith = application.DisplayName }); Assert.NotNull(fetchedApplicationsByDisplayNameExact); Assert.Equal(1, fetchedApplicationsByDisplayNameExact.Count); Assert.True(fetchedApplicationsByDisplayNameExact.First().DisplayName.StartsWith(application.DisplayName)); } finally { client.DeleteApplication(application.ObjectId); } Assert.Throws(typeof(CloudException), () => { client.GetpplicationByAppObjectId(application.ObjectId); }); } }