Persist, renew and delete sessions, refactor storage package, move reusable packages to pkg
This commit is contained in:
parent
121582f72a
commit
24f9553aa5
48 changed files with 1872 additions and 1171 deletions
35
pkg/letsencrypt/user_test.go
Normal file
35
pkg/letsencrypt/user_test.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package letsencrypt
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func tempdir() string {
|
||||
f, _ := ioutil.TempDir("", "")
|
||||
return f
|
||||
}
|
||||
|
||||
func testUser(t *testing.T, email string) {
|
||||
user, err := newUser(email)
|
||||
assert.Nil(t, err)
|
||||
key := user.GetPrivateKey()
|
||||
assert.NotNil(t, key)
|
||||
|
||||
err = saveUser(user)
|
||||
assert.Nil(t, err)
|
||||
|
||||
user, err = getUser(email)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, email, user.GetEmail())
|
||||
assert.Equal(t, key, user.GetPrivateKey())
|
||||
}
|
||||
|
||||
func TestUser(t *testing.T) {
|
||||
directory = Directory(tempdir())
|
||||
|
||||
testUser(t, "test@test.com")
|
||||
testUser(t, "")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue