package com.ruoyi.framework.config.properties;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

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

@DisplayName("LoginProperties")
class LoginPropertiesTest
{
    @Test
    @DisplayName("auth-mode=ruoyi 关闭双因子")
    void authModeRuoYiDisablesSms()
    {
        LoginProperties properties = new LoginProperties();
        properties.setAuthMode("ruoyi");
        properties.getInternetSms().setEnabled(true);
        assertFalse(properties.isSmsTwoFactorActive());
    }

    @Test
    @DisplayName("auth-mode=sms-2fa 开启双因子")
    void authModeSms2faEnablesSms()
    {
        LoginProperties properties = new LoginProperties();
        properties.setAuthMode("sms-2fa");
        properties.getInternetSms().setEnabled(false);
        assertTrue(properties.isSmsTwoFactorActive());
    }

    @Test
    @DisplayName("未设 auth-mode 时回退 internet-sms.enabled")
    void fallbackToInternetSmsEnabled()
    {
        LoginProperties properties = new LoginProperties();
        properties.getInternetSms().setEnabled(false);
        assertFalse(properties.isSmsTwoFactorActive());
        properties.getInternetSms().setEnabled(true);
        assertTrue(properties.isSmsTwoFactorActive());
    }
}
