<commit_before>package outbackcdx;

import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import outbackcdx.auth.Permit;

import java.io.*;
import java.nio.charset.Charset;
import java.util.*;

import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static outbackcdx.Json.GSON;
import static outbackcdx.NanoHTTPD.Method.*;
import static outbackcdx.NanoHTTPD.Response.Status.BAD_REQUEST;
import static outbackcdx.NanoHTTPD.Response.Status.CREATED;
import static outbackcdx.NanoHTTPD.Response.Status.OK;

public class WebappTest {
    @Rule
    public TemporaryFolder folder = new TemporaryFolder();

    private Webapp webapp;

    @Before
    public void setUp() throws IOException {
        FeatureFlags.setExperimentalAccessControl(true);
        File root = folder.newFolder();
        DataStore manager = new DataStore(root);
        webapp = new Webapp(manager, false, Collections.emptyMap());
    }

    @After
    public void tearDown() {
        FeatureFlags.setExperimentalAccessControl(false);
    }

    @Test
    public void test() throws Exception {
        POST("/test", "- 20050614070159 http://nla.gov.au/ text/html 200 AKMCCEPOOWFMGGO5635HFZXGFRLRGWIX - 337023 NLA-AU-CRAWL-000-20050614070144-00003-crawling016.archive.org\n- 20030614070159 http://example.com/ text/html 200 AKMCCEPOOWFMGGO5635HFZXGFRLRGWIX - - - 337023 NLA-AU-CRAWL-000-20050614070144-00003-crawling016.archive.org\n");
        POST("/test", "- 20060614070159 http://nla.gov.au/ text/html 200 XKMCCEPOOWFMGGO5635HFZXGFRLRGWIX - - - 337023 NLA-AU-CRAWL-000-20050614070144-00003-crawling016.archive.org\n- 20040614070159 http://example.com/ text/html 200 AKMCCEPOOWFMGGO5635HFZXGFRLRGWIX - - - 337023 NLA-AU-CRAWL-000-20060614070144-00003-crawling016.archive.org\n");
        {
            String response = GET("/test", "url", "nla.gov.au");
            assertTrue(response.indexOf("au,gov,nla)/ 20050614070159") != -1);
            assertTrue(response.indexOf("example") == -1);
        }


        {
            String response = GET("/test", "q", "type:urlquery url:http%3A%2F%2Fnla.gov.au%2F");
            assertTrue(response.indexOf("20050614070159") != -1);
            assertTrue(response.indexOf("20060614070159") != -1);
        }

        POST("/test", "@alias http://example.com/ http://www.nla.gov.au/\n- 20100614070159 http://example.com/ text/html 200 AKMCCEPOOWFMGGO5635HFZXGFRLRGWIX - - - 337023 NLA-AU-CRAWL-000-20100614070144-00003-crawling016.archive.org\n");
        {
            String response = GET("/test", "q", "type:urlquery url:http%3A%2F%2Fnla.gov.au%2F");
            assertTrue(response.indexOf("20050614070159") != -1);
            assertTrue(response.indexOf("20060614070159") != -1);<commit_msg>add required argument so test passes<commit_after>package outbackcdx;

import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import outbackcdx.auth.Permit;

import java.io.*;
import java.nio.charset.Charset;
import java.util.*;

import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static outbackcdx.Json.GSON;
import static outbackcdx.NanoHTTPD.Method.*;
import static outbackcdx.NanoHTTPD.Response.Status.BAD_REQUEST;
import static outbackcdx.NanoHTTPD.Response.Status.CREATED;
import static outbackcdx.NanoHTTPD.Response.Status.OK;

public class WebappTest {
    @Rule
    public TemporaryFolder folder = new TemporaryFolder();

    private Webapp webapp;

    @Before
    public void setUp() throws IOException {
        FeatureFlags.setExperimentalAccessControl(true);
        File root = folder.newFolder();
        DataStore manager = new DataStore(root, 0);
        webapp = new Webapp(manager, false, Collections.emptyMap());
    }

    @After
    public void tearDown() {
        FeatureFlags.setExperimentalAccessControl(false);
    }

    @Test
    public void test() throws Exception {
        POST("/test", "- 20050614070159 http://nla.gov.au/ text/html 200 AKMCCEPOOWFMGGO5635HFZXGFRLRGWIX - 337023 NLA-AU-CRAWL-000-20050614070144-00003-crawling016.archive.org\n- 20030614070159 http://example.com/ text/html 200 AKMCCEPOOWFMGGO5635HFZXGFRLRGWIX - - - 337023 NLA-AU-CRAWL-000-20050614070144-00003-crawling016.archive.org\n");
        POST("/test", "- 20060614070159 http://nla.gov.au/ text/html 200 XKMCCEPOOWFMGGO5635HFZXGFRLRGWIX - - - 337023 NLA-AU-CRAWL-000-20050614070144-00003-crawling016.archive.org\n- 20040614070159 http://example.com/ text/html 200 AKMCCEPOOWFMGGO5635HFZXGFRLRGWIX - - - 337023 NLA-AU-CRAWL-000-20060614070144-00003-crawling016.archive.org\n");
        {
            String response = GET("/test", "url", "nla.gov.au");
            assertTrue(response.indexOf("au,gov,nla)/ 20050614070159") != -1);
            assertTrue(response.indexOf("example") == -1);
        }


        {
            String response = GET("/test", "q", "type:urlquery url:http%3A%2F%2Fnla.gov.au%2F");
            assertTrue(response.indexOf("20050614070159") != -1);
            assertTrue(response.indexOf("20060614070159") != -1);
        }

        POST("/test", "@alias http://example.com/ http://www.nla.gov.au/\n- 20100614070159 http://example.com/ text/html 200 AKMCCEPOOWFMGGO5635HFZXGFRLRGWIX - - - 337023 NLA-AU-CRAWL-000-20100614070144-00003-crawling016.archive.org\n");
        {
            String response = GET("/test", "q", "type:urlquery url:http%3A%2F%2Fnla.gov.au%2F");
            assertTrue(response.indexOf("20050614070159") != -1);
            assertTrue(response.indexOf("20060614070159") != -1);
{'fraction_non_alphanumeric': 0.13323097918799046, 'fraction_numerical': 0.1175366769020812, 'mean_word_length': 3.5274131274131273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3080673', 'n_tokens_mistral': 2487, 'n_tokens_neox': 2021, 'n_words': 323}