public static void GetNonExistingLicenseShould404( [Frozen] SpIssueApi api, RandomLicenseFromListFixture license, Guid anonymousId ) { string validHref = license.Selected._links.self.href; var invalidHref = UriHelper.HackLinkReplacingGuidWithAlternateValue( anonymousId, validHref ); var apiResult = api.GetLicense( invalidHref ); // We don't want to have landed on an error page that has a StatusCode of 200 Assert.Equal( HttpStatusCode.NotFound, apiResult.StatusCode ); // Our final Location should match what we asked for Assert.Contains( invalidHref, apiResult.ResponseUri.ToString() ); }
public static void ShouldAppearInUnassignedLicensesListing( [Frozen] SpIssueApi api, RandomLicenseFromListFixture license, RandomCustomerFromListFixture customer ) { var licenseCustomerAssignmentHref = license.Selected._links.customerAssignment.href; var apiResult = api.DeleteLicenseCustomerAssignment( licenseCustomerAssignmentHref ); Assert.Contains( apiResult.StatusCode, new[] { HttpStatusCode.NoContent, HttpStatusCode.NotFound } ); // TODO assert order in xUnit.net should be reversed Verify.EventuallyWithBackOff( () => { var updated = api.GetLicenseList( "$filter=Customer eq null&$expand=Customer" ); var licenseData = VerifyResponse( updated ); // No licenses within this filtered set should show a customer link Assert.True( licenseData.All( x => x._links.customer == null ) ); // Despite asking for Customer data to be expanded, no licenses within this filtered set should have a customer property included Assert.True( licenseData.All( x => x._embedded.Customer == null ) ); } ); }
public static void GetLicenseShouldContainData( [Frozen] SpIssueApi api, RandomLicenseFromListFixture preSelectedLicense ) { var linkedAddress = preSelectedLicense.Selected._links.self.href; //Now query the API for that specific license by following the link obtained in the previous step var apiResult = api.GetLicense( linkedAddress ); Assert.Equal( HttpStatusCode.OK, apiResult.StatusCode ); //The license obtained as a separete resource should be identical to the license previously selected from the list apiResult.Data.AsSource().OfLikeness<SpIssueApi.License>() .Without( p => p._links ) .Without( p => p._embedded ) .ShouldEqual( preSelectedLicense.Selected ); }
public static void ShouldShowInAssignedLicenseListing( bool expandCustomer, [Frozen] SpIssueApi api, RandomLicenseFromListFixture license, GetRandomCustomerFixture customer ) { var licenseCustomerAssignmentHref = license.Selected._links.customerAssignment.href; var apiResult = api.PutLicenseCustomerAssignment( licenseCustomerAssignmentHref, customer.DataFromGet ); Assert.Equal( HttpStatusCode.Accepted, apiResult.StatusCode ); Verify.EventuallyWithBackOff( () => { var query = "$filter=not (Customer eq null)"; if ( expandCustomer ) query += "&$expand=Customer"; var unassignedLicenses = api.GetLicenseList( query ); var licenseData = VerifyResponse( unassignedLicenses ); // The assigned license should now appear in the assigned list Assert.Single( licenseData.Where( x => x._links.self.href == license.Selected._links.self.href ) ); // All licenses within this filtered set should show a customer link Assert.True( licenseData.All( x => x._links.customer.href != null ) ); // All licenses within this filtered set should have had their Customer data expanded Assert.Equal( expandCustomer, licenseData.All( x => x._embedded.Customer != null ) ); } ); }
public static void ShouldResetCustomerLink( [Frozen] SpIssueApi api, RandomLicenseFromListFixture license, GetRandomCustomerFixture customer ) { //Assign a customer first // (This is not strictly necessary, we just want to observe a real user actually seeing the change take place in the License list itself Put.ShouldUpdateCustomerLink( api, license, customer ); // Unassign the customer var licenseCustomerAssignmentHref = license.Selected._links.customerAssignment.href; var apiResult = api.DeleteLicenseCustomerAssignment( licenseCustomerAssignmentHref ); Assert.Contains( apiResult.StatusCode, new[] { HttpStatusCode.NoContent, HttpStatusCode.NotFound } ); // TODO assert order in xUnit.net should be reversed Verify.EventuallyWithBackOff( () => { var updated = api.GetLicense( license.Selected._links.self.href ); Assert.Equal( HttpStatusCode.OK, updated.StatusCode ); Assert.Null( updated.Data._links.customer ); } ); }
public static void ShouldUpdateCustomerLink( [Frozen] SpIssueApi api, RandomLicenseFromListFixture license, GetRandomCustomerFixture customer ) { var licenseData = license.Selected; var signedCustomerData = customer.DataFromGet; UpdateAndVerifyCustomerLink( api, licenseData, signedCustomerData ); }
public static void ShouldUpdateCustomerLinkForWellKnownTestCustomer( [Frozen] SpIssueApi api, RandomLicenseFromListFixture license, SpCustomerApi customerApi ) { var licenseData = license.Selected; var customerData = customerApi.GetCustomerList( "$filter=Name eq Test" ).Data.results.Single(); var signedCustomerData = customerApi.GetCustomer( customerData._links.self.href ).Data; UpdateAndVerifyCustomerLink( api, licenseData, signedCustomerData ); }
public static void ShouldContainData_UntestedProperties( [Frozen] SpIssueApi api, RandomLicenseFromListFixture license ) { // TODO these are here so the properties are referenced. TODO: Add roundtrip test which verifies that true and false values can propagate // There is always a flag indicating the evaluation status var dummy = license.Selected.IsEvaluation; // TODO these are here so the properties are referenced. TODO: Add roundtrip test which verifies that true and false values can propagate // There is always a flag indicating the evaluation status var dummy2 = license.Selected.IsRenewable; }
static void VerifyLinkWellFormed( RandomLicenseFromListFixture item, Func<SpIssueApi.License.Links, SpIssueApi.License.Link> linkSelector ) { var linksSet = item.Selected._links; Assert.NotNull( linksSet ); var linkToVerify = linkSelector( linksSet ); Assert.NotNull( linkToVerify ); Assert.NotEmpty( linkToVerify.href ); }
public static void ShouldHaveAWellFormedCustomerAssignmentLink( RandomLicenseFromListFixture item ) { VerifyLinkWellFormed( item, links => links.customerAssignment ); }
public static void ShouldHaveAWellFormedSelfLink( RandomLicenseFromListFixture item ) { VerifyLinkWellFormed( item, links => links.self ); }
public static void ShouldContainData( RandomLicenseFromListFixture license ) { // There should always be valid Activation Key Assert.NotEmpty( license.Selected.ActivationKey ); // There should always be a Product Label Assert.NotEmpty( license.Selected.ProductLabel ); // There should always be a Version Label Assert.NotEmpty( license.Selected.VersionLabel ); // There is always an IssueDate Assert.NotEqual( default( string ), license.Selected.IssueDate ); }