package com.foxx.androidcast.remoteaccess.control;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class RemoteAccessControlAuthTest {

    @Test
    public void bearerHeaderAuthorized() {
        assertTrue(RemoteAccessControlAuth.isAuthorized(
                "secret", "Bearer secret", ""));
        assertFalse(RemoteAccessControlAuth.isAuthorized(
                "secret", "Bearer wrong", ""));
    }

    @Test
    public void queryTokenAuthorized() {
        assertTrue(RemoteAccessControlAuth.isAuthorized(
                "abc", "", "abc"));
    }

    @Test
    public void normalizePath_stripsQuery() {
        assertEquals("/api/settings", RemoteAccessControlAuth.normalizePath("/api/settings?token=x"));
    }
}
