WIP Working on authkeys + tests
This commit is contained in:
parent
03bb32083b
commit
486faa9656
3 changed files with 50 additions and 0 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
_ "github.com/jinzhu/gorm/dialects/sqlite" // sql driver
|
||||
|
||||
|
@ -48,6 +49,7 @@ func (s *Suite) TearDownSuite(c *check.C) {
|
|||
|
||||
func (*Suite) TestCreatePreAuthKey(c *check.C) {
|
||||
_, err := h.CreatePreAuthKey("bogus", true, nil)
|
||||
|
||||
c.Assert(err, check.NotNil)
|
||||
|
||||
n, err := h.CreateNamespace("test")
|
||||
|
@ -73,3 +75,22 @@ func (*Suite) TestCreatePreAuthKey(c *check.C) {
|
|||
// Make sure the Namespace association is populated
|
||||
c.Assert((*keys)[0].Namespace.Name, check.Equals, n.Name)
|
||||
}
|
||||
|
||||
func (*Suite) TestExpiredPreAuthKey(c *check.C) {
|
||||
n, err := h.CreateNamespace("test2")
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
now := time.Now()
|
||||
pak, err := h.CreatePreAuthKey(n.Name, true, &now)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
p, err := h.checkKeyValidity(pak.Key)
|
||||
c.Assert(err, check.Equals, errorAuthKeyExpired)
|
||||
c.Assert(p, check.IsNil)
|
||||
}
|
||||
|
||||
func (*Suite) TestPreAuthKeyDoesNotExist(c *check.C) {
|
||||
p, err := h.checkKeyValidity("potatoKey")
|
||||
c.Assert(err, check.Equals, errorAuthKeyNotFound)
|
||||
c.Assert(p, check.IsNil)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue