//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleConflictResponseFromInitiateUploadTargetAndContinueOnUserConsent() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleConflictResponseFromInitiateUploadTargetAndContinueOnUserConsent() { ControlledOutsideWorld outsideWorld = new ControlledOutsideWorld(_fs); outsideWorld.WithPromptResponse("my-username"); // prompt for username outsideWorld.WithPasswordResponse("pass".ToCharArray()); // prompt for password outsideWorld.WithPromptResponse("y"); // prompt for consent to overwrite db HttpCopier copier = new HttpCopier(outsideWorld); Path source = CreateDump(); long sourceLength = _fs.getFileSize(source.toFile()); string authorizationTokenResponse = "abc"; string signedURIPath = "/signed"; string uploadLocationPath = "/upload"; WireMock.stubFor(AuthenticationRequest(true).willReturn(SuccessfulAuthorizationResponse(authorizationTokenResponse))); WireMock.stubFor(AuthenticationRequest(false).willReturn(aResponse().withStatus(HTTP_CONFLICT))); WireMock.stubFor(InitiateUploadTargetRequest(authorizationTokenResponse).willReturn(SuccessfulInitiateUploadTargetResponse(signedURIPath))); // and just the rest of the responses so that the upload can continue w/o failing WireMock.stubFor(InitiateUploadRequest(signedURIPath).willReturn(SuccessfulInitiateUploadResponse(uploadLocationPath))); WireMock.stubFor(ResumeUploadRequest(uploadLocationPath, sourceLength).willReturn(SuccessfulResumeUploadResponse())); WireMock.stubFor(TriggerImportRequest(authorizationTokenResponse).willReturn(SuccessfulTriggerImportResponse())); WireMock.stubFor(FirstStatusPollingRequest(authorizationTokenResponse)); WireMock.stubFor(SecondStatusPollingRequest(authorizationTokenResponse)); // when AuthenticateAndCopy(copier, source, "user", "pass".ToCharArray()); // then there should be one request w/o the user consent and then (since the user entered 'y') one w/ user consent verify(postRequestedFor(urlEqualTo("/import/auth")).withHeader("Confirmed", equalTo("false"))); verify(postRequestedFor(urlEqualTo("/import/auth")).withHeader("Confirmed", equalTo("true"))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleUnexpectedResponseFromInitiateUploadTargetRequest() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleUnexpectedResponseFromInitiateUploadTargetRequest() { ControlledOutsideWorld outsideWorld = new ControlledOutsideWorld(_fs); outsideWorld.WithPromptResponse("my-username"); // prompt for username outsideWorld.WithPromptResponse("n"); // prompt for consent to overwrite db HttpCopier copier = new HttpCopier(outsideWorld); Path source = CreateDump(); string authorizationTokenResponse = "abc"; WireMock.stubFor(AuthenticationRequest(false).willReturn(SuccessfulAuthorizationResponse(authorizationTokenResponse))); WireMock.stubFor(InitiateUploadTargetRequest(authorizationTokenResponse).willReturn(aResponse().withStatus(HTTP_BAD_GATEWAY))); // when AssertThrows(typeof(CommandFailed), allOf(containsString("Unexpected response"), containsString("Initiating upload target")), () => authenticateAndCopy(copier, source, "user", "pass".ToCharArray())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleConflictResponseFromAuthenticationWithoutUserConsent() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleConflictResponseFromAuthenticationWithoutUserConsent() { ControlledOutsideWorld outsideWorld = new ControlledOutsideWorld(_fs); outsideWorld.WithPromptResponse("my-username"); // prompt for username outsideWorld.WithPromptResponse("n"); // prompt for consent to overwrite db HttpCopier copier = new HttpCopier(outsideWorld); Path source = CreateDump(); string authorizationTokenResponse = "abc"; string signedURIPath = "/signed"; WireMock.stubFor(AuthenticationRequest(false).willReturn(aResponse().withStatus(HTTP_CONFLICT))); WireMock.stubFor(AuthenticationRequest(true).willReturn(SuccessfulAuthorizationResponse(authorizationTokenResponse))); WireMock.stubFor(InitiateUploadTargetRequest(authorizationTokenResponse).willReturn(SuccessfulInitiateUploadTargetResponse(signedURIPath))); // when AssertThrows(typeof(CommandFailed), containsString("No consent to overwrite"), () => authenticateAndCopy(copier, source, "user", "pass".ToCharArray())); // then there should be one request w/o the user consent and then (since the user entered 'y') one w/ user consent verify(postRequestedFor(urlEqualTo("/import/auth")).withHeader("Confirmed", equalTo("false"))); verify(0, postRequestedFor(urlEqualTo("/import/auth")).withHeader("Confirmed", equalTo("true"))); }