mirror of https://github.com/alibaba/arthas.git
update download link to arthas.aliyun.com. #1411
parent
6f4391aaf2
commit
2edd2389cd
@ -1,64 +1,51 @@
|
||||
package com.taobao.arthas.boot;
|
||||
|
||||
import com.taobao.arthas.common.IOUtils;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import static com.taobao.arthas.boot.DownloadUtils.*;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class DownloadUtilsTest {
|
||||
@Rule
|
||||
public TemporaryFolder rootFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void testReadMavenReleaseVersion() {
|
||||
//check 'center' repo
|
||||
String releaseVersion = readMavenReleaseVersion(readMavenMetaData("center", false));
|
||||
public void testReadReleaseVersion() {
|
||||
String releaseVersion = DownloadUtils.readLatestReleaseVersion();
|
||||
Assert.assertNotNull(releaseVersion);
|
||||
Assert.assertNotEquals("releaseVersion is empty", "", releaseVersion.trim());
|
||||
//check 'aliyun' repo
|
||||
String aliyunReleaseVersion = readMavenReleaseVersion(readMavenMetaData("aliyun", false));
|
||||
Assert.assertEquals("releaseVersion is not match between repo 'center' and 'aliyun'", releaseVersion, aliyunReleaseVersion);
|
||||
System.err.println(releaseVersion);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadAllMavenVersion() {
|
||||
Assert.assertNotEquals(new ArrayList<String>(), readAllMavenVersion(readMavenMetaData("center", false)));
|
||||
public void testReadAllVersions() {
|
||||
List<String> versions = DownloadUtils.readRemoteVersions();
|
||||
Assert.assertEquals("", true, versions.contains("3.1.7"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRepoUrl() {
|
||||
Assert.assertEquals("http", getRepoUrl("https/", true));
|
||||
Assert.assertEquals("https://repo1.maven.org/maven2", getRepoUrl("center", false));
|
||||
Assert.assertEquals("https://maven.aliyun.com/repository/public", getRepoUrl("aliyun", false));
|
||||
public void testAliyunDownload() throws IOException {
|
||||
String version = "3.3.7";
|
||||
File folder = rootFolder.newFolder();
|
||||
System.err.println(folder.getAbsolutePath());
|
||||
DownloadUtils.downArthasPackaging("aliyun", false, version, folder.getAbsolutePath());
|
||||
|
||||
File as = new File(folder, version + File.separator + "arthas" + File.separator + "as.sh");
|
||||
Assert.assertTrue(as.exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadMavenMetaData() throws IOException {
|
||||
String url = "https://repo1.maven.org/maven2/com/taobao/arthas/arthas-packaging/maven-metadata.xml";
|
||||
Assert.assertEquals(IOUtils.toString(new URL(url).openStream()), readMavenMetaData("center", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXXE() throws Exception {
|
||||
try {
|
||||
//from https://blog.spoock.com/2018/10/23/java-xxe/
|
||||
String playload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<!DOCTYPE root [\n" +
|
||||
" <!ENTITY xxe SYSTEM \"../NOTICE\">\n" +
|
||||
" ]>\n" +
|
||||
"<evil>&xxe;</evil>";
|
||||
Document document = transformMavenMetaData(playload);
|
||||
} catch (org.xml.sax.SAXParseException e) {
|
||||
String message = e.getMessage();
|
||||
Assert.assertTrue("XXE is not disabled", message.contains("disallow-doctype-decl"));
|
||||
return;
|
||||
}
|
||||
Assert.fail("XXE is not disabled");
|
||||
public void testCenterDownload() throws IOException {
|
||||
String version = "3.1.7";
|
||||
File folder = rootFolder.newFolder();
|
||||
System.err.println(folder.getAbsolutePath());
|
||||
DownloadUtils.downArthasPackaging("center", false, version, folder.getAbsolutePath());
|
||||
|
||||
File as = new File(folder, version + File.separator + "arthas" + File.separator + "as.sh");
|
||||
Assert.assertTrue(as.exists());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue