Test: file compress / download

This commit is contained in:
HFO4
2019-12-14 14:28:01 +08:00
parent 03dcd9a9e0
commit ca07a94d41
15 changed files with 367 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package auth
import (
"database/sql"
"fmt"
"github.com/DATA-DOG/go-sqlmock"
model "github.com/HFO4/cloudreve/models"
"github.com/HFO4/cloudreve/pkg/util"
@@ -9,6 +10,7 @@ import (
"github.com/jinzhu/gorm"
"github.com/stretchr/testify/assert"
"testing"
"time"
)
var mock sqlmock.Sqlmock
@@ -64,6 +66,16 @@ func TestHMACAuth_Check(t *testing.T) {
sign := auth.Sign("content", 1)
asserts.Error(auth.Check("content", sign+":"))
}
// 过期日期格式错误
{
asserts.Error(auth.Check("content", "ErrAuthFailed:ErrAuthFailed"))
}
// 签名有误
{
asserts.Error(auth.Check("content", fmt.Sprintf("sign:%d", time.Now().Unix()+10)))
}
}
func TestInit(t *testing.T) {