func TestAuthenticate(t *testing.T) {
	defer testhelpers.ClearDb()
	authBackend, _ := InitJwtAuthBackend()
	dummyu := user.DummyUser()
	dummyu.Save()
	u := user.DummyUser()
	loggedin := authBackend.Authenticate(&u)
	if !loggedin {
		t.Error("Expected right user credentials to be valid, got invalid.")
	}
	u2 := user.User{
		Name:     "Marc",
		Email:    "marc@marc.com",
		Password: "justhacking",
	}
	loggedin = authBackend.Authenticate(&u2)
	if loggedin {
		t.Error("Expected wrong user authentication to be invalid, go valid.")
	}
}
Test valid and invalid authentication
package auth
import (
	"fmt"
	"strings"
	"testing"
	jwt "github.com/dgrijalva/jwt-go"
	"github.com/nathandao/vantaa/services/models/user"
	"github.com/nathandao/vantaa/testhelpers"
)
func TestTokenGeneration(t *testing.T) {
	defer testhelpers.ClearDb()
	authBackend, _ := InitJwtAuthBackend()
	dummyu := user.DummyUser()
	u, _ := dummyu.Save()
	token, err := authBackend.GenerateToken(u)
	if err != nil {
		t.Error(
			"When token data is valid,",
			"Expected token generation to be valid",
			"got error", err,
		)
	}
	if len(strings.Split(token, ".")) != 3 {
		t.Error("Wrong token format was generated.")
	}
}