package com.ai.trackwalker.model;

import org.junit.jupiter.api.Test;
import org.springframework.web.server.ResponseStatusException;

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

class ModelRuntimeDeploymentServiceTest {
    @Test
    void normalizesServiceUrlAndPaths() {
        assertEquals("http://vision-inference:8101",
                ModelRuntimeDeploymentService.normalizeServiceUrl("http://vision-inference:8101/"));
        assertEquals("/api/v1/runtime",
                ModelRuntimeDeploymentService.normalizePath("api/v1/runtime", null));
    }

    @Test
    void rejectsUnsafeEndpointDefinitions() {
        assertThrows(ResponseStatusException.class,
                () -> ModelRuntimeDeploymentService.normalizeServiceUrl("file:///models/model.onnx"));
        assertThrows(ResponseStatusException.class,
                () -> ModelRuntimeDeploymentService.normalizeServiceUrl("http://user:password@host:8101"));
        assertThrows(ResponseStatusException.class,
                () -> ModelRuntimeDeploymentService.normalizePath("../actuator/env", null));
    }
}
