@Test
  public void checkAgentStatusShouldIncludeMd5Checksum_forAgent_forLauncher_whenChecksumsAreCached()
      throws Exception {
    when(pluginsZip.md5()).thenReturn("plugins-zip-md5");

    controller.checkAgentStatus(response);

    try (InputStream stream =
        new TFSJarDetector.DevelopmentServerTFSJarDetector(systemEnvironment)
            .getJarURL()
            .openStream()) {
      assertEquals(
          md5DigestOfStream(stream),
          response.getHeader(SystemEnvironment.AGENT_TFS_SDK_MD5_HEADER));
    }

    try (InputStream stream = JarDetector.create(systemEnvironment, "agent-launcher.jar")) {
      assertEquals(
          md5DigestOfStream(stream),
          response.getHeader(SystemEnvironment.AGENT_LAUNCHER_CONTENT_MD5_HEADER));
    }

    try (InputStream stream = JarDetector.create(systemEnvironment, "agent.jar")) {
      assertEquals(
          md5DigestOfStream(stream),
          response.getHeader(SystemEnvironment.AGENT_CONTENT_MD5_HEADER));
    }

    assertEquals(
        "plugins-zip-md5", response.getHeader(SystemEnvironment.AGENT_PLUGINS_ZIP_MD5_HEADER));
    assertEquals("8443", response.getHeader("Cruise-Server-Ssl-Port"));
  }
  @Test
  public void headShouldIncludeMd5Checksum_forPluginsZip() throws Exception {
    when(pluginsZip.md5()).thenReturn("md5");
    controller.checkAgentPluginsZipStatus(response);

    assertEquals("8443", response.getHeader("Cruise-Server-Ssl-Port"));
    assertEquals("md5", response.getHeader("Content-MD5"));
    verify(pluginsZip).md5();
  }
  @Test
  public void shouldReturnAgentPluginsZipWhenRequested() throws Exception {
    File pluginZipFile = TestFileUtil.createTempFile("plugins.zip");
    FileUtils.writeStringToFile(pluginZipFile, "content");
    when(pluginsZip.md5()).thenReturn("md5");
    when(systemEnvironment.get(SystemEnvironment.ALL_PLUGINS_ZIP_PATH))
        .thenReturn(pluginZipFile.getAbsolutePath());

    controller.downloadPluginsZip(response);

    String actual = response.getContentAsString();
    assertEquals("application/octet-stream", response.getContentType());
    assertEquals("content", actual);
  }
예제 #4
0
 @Override
 public void handle() {
   pluginsZip.create();
 }