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 com.foxx.androidcast.remoteaccess.RemoteAccessMode;
import com.foxx.androidcast.remoteaccess.RemoteAccessVpnRouting;

import org.junit.Test;

public class RemoteAccessControlPrefsMirrorTest {

    @Test
    public void parseApplyPatch_readsModeAndScopes() {
        String body = "{\"remote_access_mode\":\"WIREGUARD\","
                + "\"vpn_route_scope\":\"FULL_TUNNEL\","
                + "\"vpn_app_scope\":\"THIS_APP_ONLY\"}";
        RemoteAccessControlPrefsMirror.ApplyResult r =
                RemoteAccessControlPrefsMirror.parseApplyPatch(body);
        assertTrue(r.ok);
        assertEquals(RemoteAccessMode.WIREGUARD, r.mode);
        assertEquals(RemoteAccessVpnRouting.RouteScope.FULL_TUNNEL, r.routeScope);
        assertEquals(RemoteAccessVpnRouting.AppScope.THIS_APP_ONLY, r.appScope);
    }

    @Test
    public void parseApplyPatch_rejectsInvalidJson() {
        RemoteAccessControlPrefsMirror.ApplyResult r =
                RemoteAccessControlPrefsMirror.parseApplyPatch("{");
        assertFalse(r.ok);
    }
}
