package io.wealthwizards.appsynctesting.utils;

import java.util.HashMap;
import java.util.Map;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

@DisplayName("$util.http")
public class HttpTest {
    @Test
    @DisplayName(".copyHeaders")
    void shouldNormaliseAndCopyAllExceptExcluded() {
        var http = new Http();

        var headers = new HashMap<>(Map.of(
                "Cookie", "abc",
                "cOokie", "def",
                "content-type", "application/malicious",
                "user-agent", "Third Party API",
                "expectation", "Something",
                "transfer-encoding", "encode",
                "content-length", "118",
                "x-correlation-id", "uuid-here"
        ));

        var actual = http.copyHeaders(headers);
        var expected = Map.of(
                "cookie", "def",
                "x-correlation-id", "uuid-here"
        );

        assertEquals(expected, actual);
    }
}
