summaryrefslogtreecommitdiffstats
path: root/model/access_test.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-09-16 15:49:12 -0400
committerJoramWilander <jwawilander@gmail.com>2015-09-16 15:49:12 -0400
commit47e6a33a4505e13ba4edf37ff1f8fbdadb279ee3 (patch)
tree9d798d908b3a76d6e228f39872e74cccfc27ad35 /model/access_test.go
parent7e418714bce067172e527359f391943459b3bd48 (diff)
downloadchat-47e6a33a4505e13ba4edf37ff1f8fbdadb279ee3.tar.gz
chat-47e6a33a4505e13ba4edf37ff1f8fbdadb279ee3.tar.bz2
chat-47e6a33a4505e13ba4edf37ff1f8fbdadb279ee3.zip
Implement OAuth2 service provider functionality.
Diffstat (limited to 'model/access_test.go')
-rw-r--r--model/access_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/model/access_test.go b/model/access_test.go
new file mode 100644
index 000000000..e385c0586
--- /dev/null
+++ b/model/access_test.go
@@ -0,0 +1,41 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestAccessJson(t *testing.T) {
+ a1 := AccessData{}
+ a1.AuthCode = NewId()
+ a1.Token = NewId()
+ a1.RefreshToken = NewId()
+
+ json := a1.ToJson()
+ ra1 := AccessDataFromJson(strings.NewReader(json))
+
+ if a1.Token != ra1.Token {
+ t.Fatal("tokens didn't match")
+ }
+}
+
+func TestAccessIsValid(t *testing.T) {
+ ad := AccessData{}
+
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("should have failed")
+ }
+
+ ad.AuthCode = NewId()
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("should have failed")
+ }
+
+ ad.Token = NewId()
+ if err := ad.IsValid(); err != nil {
+ t.Fatal(err)
+ }
+}