package com.github.mike10004.chromecookieimplant;

import io.github.mike10004.crxtool.CrxMetadata;
import io.github.mike10004.crxtool.CrxParser;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
import java.util.stream.Stream;

import static org.junit.Assert.*;

public class ChromeCookieImplanterStaticTest {

    @Test
    public void getCrxResourceOrDie() throws Exception {
        System.out.println(readMetadata());
    }

    private CrxMetadata readMetadata() throws IOException {
        URL resource = ChromeCookieImplanter.getCrxResourceOrDie();
        assertNotNull(resource);
        try (InputStream in = resource.openStream()) {
            return CrxParser.getDefault().parseMetadata(in);
        }
    }

    /**
     * Tests that the extension ID remains the same between our official builds.
     * @throws Exception
     */
    @Test
    public void extensionIdStable() throws Exception {
        System.getProperty()
        CrxMetadata metadata = readMetadata();
        String expectedExtensionId = "kaoadjmhchcekjlnhdmeennkgjeacdio";
        assertEquals("id", expectedExtensionId, metadata.id);
    }

    @Test
    public void info() throws Exception {
        Properties p = new Properties();
        try (InputStream in = ChromeCookieImplanter.class.getResourceAsStream("/chrome-cookie-implant/info.properties")) {
            assertNotNull("resource input stream", in);
            p.load(in);
        }
        Stream.of("project.groupId", "project.artifactId", "project.version").forEach(key -> {
            String value = p.getProperty(key);
            assertFalse("starts with ${ - " + key, value.startsWith("${"));
        });
    }

}
@@ -800,413 +800,8 @@
  %7D%0A%0A
-    /**%0A     * Tests that the extension ID remains the same between our official builds.%0A     * @throws Exception%0A     */%0A    @Test%0A    public void extensionIdStable() throws Exception %7B%0A        System.getProperty()%0A        CrxMetadata metadata = readMetadata();%0A        String expectedExtensionId = %22kaoadjmhchcekjlnhdmeennkgjeacdio%22;%0A        assertEquals(%22id%22, expectedExtensionId, metadata.id);%0A    %7D%0A%0A
     

remove extension id stability test