package com.qmth.boot.test.core.fss;

import com.qmth.boot.core.fss.utils.FssSigner;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import java.time.Duration;

public class FssSignerTest {

    @Test
    public void test() {
        FssSigner signer = new FssSigner("public", "qmth");
        String path = "/test/1.txt";
        Duration expire = Duration.ofSeconds(10);
        String[] params = StringUtils.split(signer.buildUrlParam(path, expire), "&");
        long expireTime = Long.parseLong(params[0].split("=")[1]);
        String bucket = params[1].split("=")[1];
        String signature = params[2].split("=")[1];
        signer.validate(bucket, path, expireTime, signature);
    }
}
