*: fix auth tests - don't leave repo dirty
This commit is contained in:
parent
ed0c5ee525
commit
8a05e61feb
|
@ -3,6 +3,7 @@ package home
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -10,13 +11,17 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAuth(t *testing.T) {
|
func TestAuth(t *testing.T) {
|
||||||
fn := "./sessions.db"
|
config.ourWorkingDir = "."
|
||||||
|
fn := filepath.Join(config.getDataDir(), "sessions.db")
|
||||||
|
|
||||||
|
_ = os.RemoveAll(config.getDataDir())
|
||||||
|
defer func() { _ = os.RemoveAll(config.getDataDir()) }()
|
||||||
|
|
||||||
users := []User{
|
users := []User{
|
||||||
User{Name: "name", PasswordHash: "$2y$05$..vyzAECIhJPfaQiOK17IukcQnqEgKJHy0iETyYqxn3YXJl8yZuo2"},
|
User{Name: "name", PasswordHash: "$2y$05$..vyzAECIhJPfaQiOK17IukcQnqEgKJHy0iETyYqxn3YXJl8yZuo2"},
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Remove(fn)
|
os.MkdirAll(config.getDataDir(), 0755)
|
||||||
config.ourWorkingDir = "."
|
|
||||||
a := InitAuth(fn, users)
|
a := InitAuth(fn, users)
|
||||||
|
|
||||||
assert.True(t, a.CheckSession("notfound") == -1)
|
assert.True(t, a.CheckSession("notfound") == -1)
|
||||||
|
|
Loading…
Reference in New Issue