public void GivenImportProxy_WhenSettingsNotSupplied_ThenImportProxy() { // Arrange var fixture = new ApigeeAliasesFixture(this.output); ApigeeAliases.ApigeeProxyManagementService = fixture.ApigeeProxyManagementService; fixture.UseSuccessfulImportResponse(); // Act ApigeeAliases.ImportProxy(fixture.ContextMock.Object, "org", "proxy", fixture.GetProxyZipFilePath()); // Assert Assert.Equal(new Uri("https://api.enterprise.apigee.com/v1/organizations/org/apis?action=import&name=proxy&validate=true"), fixture.RequestUrl); }
public void GivenImportProxy_WhenImportFails_ThenUsefulErrorShown() { // Arrange var fixture = new ApigeeAliasesFixture(this.output); ApigeeAliases.ApigeeProxyManagementService = fixture.ApigeeProxyManagementService; fixture.UseFailedImportResponse(); // Act try { ApigeeAliases.ImportProxy(fixture.ContextMock.Object, "org", "proxy", fixture.GetProxyZipFilePath()); } catch (Exception ex) { Assert.StartsWith("Apigee returned BadRequest", ex.Message); } }
public void GivenImportProxy_WhenCredentialsSupplied_ThenCredentialsAddedToAuthorizationHeader() { // Arrange var fixture = new ApigeeAliasesFixture(this.output); ApigeeAliases.ApigeeProxyManagementService = fixture.ApigeeProxyManagementService; fixture.UseSuccessfulImportResponse(); // Act var credentials = new Credentials { Username = "******", Password = "******" }; ApigeeAliases.ImportProxy(fixture.ContextMock.Object, "org", "proxy", fixture.GetProxyZipFilePath(), new ImportProxySettings { Credentials = credentials }); // Assert Assert.Equal("Basic", fixture.FakeResponseHandler.Requests.First().Headers.Authorization.Scheme); }
public void GivenImportProxy_WhenImportFailsDueToValidation_ThenValidationErrorIsLoggedAndExceptionThrown() { // Arrange var fixture = new ApigeeAliasesFixture(this.output); ApigeeAliases.ApigeeProxyManagementService = fixture.ApigeeProxyManagementService; fixture.UseValidationFailedImportResponse(); // Act try { ApigeeAliases.ImportProxy(fixture.ContextMock.Object, "org", "proxy", fixture.GetProxyZipFilePath()); } catch (Exception ex) { Assert.StartsWith("Apigee returned BadRequest", ex.Message); } Assert.Contains(fixture.LogMessages, message => message.Contains("BadElement")); }