package com.tuoheng;

import com.tuoheng.model.param.ClientRoleDto;
import com.tuoheng.third.service.impl.ThirdServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author xiaoying
 * @Date 2023/2/21 11:12
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class passwordTest {

    @Autowired
    PasswordEncoder passwordEncoder;
    @Autowired
    ThirdServiceImpl thirdService;
    /*
    明文，加密成密文
     */
    @Test
    public void test1() {
        String password = "123";
        String encode = passwordEncoder.encode(password);
        System.out.println(encode);
        //$2a$10$K.gyCkGOvQAbBQg.HAai1O5cvE./sVWLCfiLURhCVjhHVt1SSOAi6
    }

    //判断明文和密文是否一致
    @Test
    public void test2() {
        String password = "123";
        String encode = "$2a$10$apjRNzmuDrDx2DiGAaVaZeM/HzyxMU3bOEWpZwYsbp5nc9jv1A7FK";
        boolean matches = passwordEncoder.matches(password, encode);
        System.out.println(matches);
    }

    @Test
    public void getModelList() {

        List<ClientRoleDto> list =new ArrayList<>();

        ClientRoleDto clientRoleDto = new ClientRoleDto();
        clientRoleDto.setServiceId("85b0fe8a352c4dbda6191a382362a81a");
        ClientRoleDto clientRoleDto2 = new ClientRoleDto();
        clientRoleDto.setServiceId("e5137ec466db426c96a8b194a6853b77");
        list.add(clientRoleDto);
        list.add(clientRoleDto2);

        List<ClientRoleDto> modelList = thirdService.getModelList(list);
        System.out.println("modelList = " + modelList);
    }
}
