package kr.co.jinwoosi.clfd.framework.security.config;

import kr.co.jinwoosi.clfd.framework.security.mapper.UserMapper;
import kr.co.jinwoosi.clfd.framework.security.model.User;
import kr.co.jinwoosi.clfd.framework.util.StrUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.UUID;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
        "classpath:config/spring/context-datasource.xml",
        "classpath:config/spring/context-mybatis.xml",
        "classpath:config/spring/context-common.xml",
        "classpath:config/spring/context-transaction.xml"
})
public class EncryptConfigTest {

    @Autowired
    private PasswordEncoder passwordEncoder;
    @Autowired
    private UserMapper userMapper;

    public void test() {
        String ddd = passwordEncoder.encode("ddd");
        System.out.println(ddd);
        User user = new User();
        user.setUserLoginId("user1");
        User login = userMapper.login(user);
        System.out.println(login.getAuthStCd());
    }

    @Test
    public void uuid() {
         String uuid = UUID.randomUUID().toString();
        System.out.println(uuid);

        String randomPassword = StrUtil.getRandomPassword(16);
        System.out.println(randomPassword);
    }
}
