diff options
author | enahum <nahumhbl@gmail.com> | 2017-04-03 14:37:58 -0300 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2017-04-03 10:37:58 -0700 |
commit | 1cbe6e797517089140ee2db12d73c0781f5e3e6b (patch) | |
tree | 5671819dcbfdc6f359410e3558135090d3724e4c /model/access_test.go | |
parent | 68bb5a2ec85a6d34726a137bad65157d0ff65247 (diff) | |
download | chat-1cbe6e797517089140ee2db12d73c0781f5e3e6b.tar.gz chat-1cbe6e797517089140ee2db12d73c0781f5e3e6b.tar.bz2 chat-1cbe6e797517089140ee2db12d73c0781f5e3e6b.zip |
Add more OAuth unit tests (#5946)
Diffstat (limited to 'model/access_test.go')
-rw-r--r-- | model/access_test.go | 54 |
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) } |