示例#1
0
func TestOAuthStoreGetAccessData(t *testing.T) {
	Setup()

	a1 := model.AccessData{}
	a1.AuthCode = model.NewId()
	a1.Token = model.NewId()
	a1.RefreshToken = model.NewId()
	Must(store.OAuth().SaveAccessData(&a1))

	if result := <-store.OAuth().GetAccessData(a1.Token); result.Err != nil {
		t.Fatal(result.Err)
	} else {
		ra1 := result.Data.(*model.AccessData)
		if a1.Token != ra1.Token {
			t.Fatal("tokens didn't match")
		}
	}

	if err := (<-store.OAuth().GetAccessDataByAuthCode(a1.AuthCode)).Err; err != nil {
		t.Fatal(err)
	}

	if err := (<-store.OAuth().GetAccessDataByAuthCode("junk")).Err; err != nil {
		t.Fatal(err)
	}
}
示例#2
0
func TestOAuthStoreSaveAccessData(t *testing.T) {
	Setup()

	a1 := model.AccessData{}
	a1.AuthCode = model.NewId()
	a1.Token = model.NewId()
	a1.RefreshToken = model.NewId()

	if err := (<-store.OAuth().SaveAccessData(&a1)).Err; err != nil {
		t.Fatal(err)
	}
}
示例#3
0
func TestOAuthStoreRemoveAccessData(t *testing.T) {
	Setup()

	a1 := model.AccessData{}
	a1.AuthCode = model.NewId()
	a1.Token = model.NewId()
	a1.RefreshToken = model.NewId()
	Must(store.OAuth().SaveAccessData(&a1))

	if err := (<-store.OAuth().RemoveAccessData(a1.Token)).Err; err != nil {
		t.Fatal(err)
	}

	if result := <-store.OAuth().GetAccessDataByAuthCode(a1.AuthCode); result.Err != nil {
		t.Fatal(result.Err)
	} else {
		if result.Data != nil {
			t.Fatal("did not delete access token")
		}
	}
}