@Test public void fail_if_integrity_of_compressed_download_is_not_valid() throws Exception { FileAndMd5 jar = new FileAndMd5(); enqueueCompressedDownload(jar, false); expectISE("foo", "was expected to have checksum invalid_hash but had "); InstalledPlugin plugin = newInstalledPlugin("foo", jar.md5); underTest.get(plugin).get(); }
@Test public void fail_if_md5_header_is_missing_from_response() throws IOException { File tempJar = temp.newFile(); enqueueDownload(tempJar, null); InstalledPlugin plugin = newInstalledPlugin("foo", "abc"); expectISE("foo", "did not return header Sonar-MD5"); underTest.get(plugin); }
@Test public void fail_if_integrity_of_download_is_not_valid() throws IOException { FileAndMd5 tempJar = new FileAndMd5(); enqueueDownload(tempJar.file, "invalid_hash"); InstalledPlugin plugin = newInstalledPlugin("foo", "abc"); expectISE("foo", "was expected to have checksum invalid_hash but had " + tempJar.md5); underTest.get(plugin); }
@Test public void fail_if_compressed_download_cannot_be_uncompressed() { MockResponse response = new MockResponse().setBody("not binary"); response.setHeader("Sonar-MD5", DigestUtils.md5Hex("not binary")); response.setHeader("Sonar-UncompressedMD5", "abc"); response.setHeader("Sonar-Compression", "pack200"); server.enqueue(response); expectISE("foo", "Pack200 error"); InstalledPlugin plugin = newInstalledPlugin("foo", "abc"); underTest.get(plugin).get(); }
@Test public void fail_if_server_returns_error() { server.enqueue(new MockResponse().setResponseCode(500)); InstalledPlugin plugin = newInstalledPlugin("foo", "abc"); expectISE("foo", "returned code 500"); underTest.get(plugin); }