summaryrefslogtreecommitdiffstats
path: root/model/access_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/access_test.go')
-rw-r--r--model/access_test.go54
1 files changed, 52 insertions, 2 deletions
diff --git a/model/access_test.go b/model/access_test.go
index 0eca302ba..77b4cf15b 100644
--- a/model/access_test.go
+++ b/model/access_test.go
@@ -27,12 +27,32 @@ func TestAccessIsValid(t *testing.T) {
ad := AccessData{}
if err := ad.IsValid(); err == nil {
- t.Fatal("should have failed")
+ t.Fatal()
+ }
+
+ ad.ClientId = NewRandomString(28)
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("Should have failed Client Id")
+ }
+
+ ad.ClientId = ""
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("Should have failed Client Id")
}
ad.ClientId = NewId()
if err := ad.IsValid(); err == nil {
- t.Fatal("should have failed")
+ t.Fatal()
+ }
+
+ ad.UserId = NewRandomString(28)
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("Should have failed User Id")
+ }
+
+ ad.UserId = ""
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("Should have failed User Id")
}
ad.UserId = NewId()
@@ -40,7 +60,37 @@ func TestAccessIsValid(t *testing.T) {
t.Fatal("should have failed")
}
+ ad.Token = NewRandomString(22)
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("Should have failed Token")
+ }
+
ad.Token = NewId()
+ if err := ad.IsValid(); err == nil {
+ t.Fatal()
+ }
+
+ ad.RefreshToken = NewRandomString(28)
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("Should have failed Refresh Token")
+ }
+
+ ad.RefreshToken = NewId()
+ if err := ad.IsValid(); err == nil {
+ t.Fatal()
+ }
+
+ ad.RedirectUri = ""
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("Should have failed Redirect URI not set")
+ }
+
+ ad.RedirectUri = NewRandomString(28)
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("Should have failed invalid URL")
+ }
+
+ ad.RedirectUri = "http://example.com"
if err := ad.IsValid(); err != nil {
t.Fatal(err)
}