mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 13:47:05 +02:00
Basic "scotty auth" implementation
This commit is contained in:
parent
8b227cb514
commit
14d944c7ad
8 changed files with 238 additions and 6 deletions
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/storage"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
func TestTimestampUpdate(t *testing.T) {
|
||||
|
@ -50,3 +51,23 @@ func TestTimestampUpdate(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Equal(t, newTimestamp.Unix(), timestamp.Unix())
|
||||
}
|
||||
|
||||
func TestOAuth2TokenUpdate(t *testing.T) {
|
||||
db, err := storage.New(":memory:")
|
||||
require.NoError(t, err)
|
||||
|
||||
service := "spotify"
|
||||
token, err := db.GetOAuth2Token(service)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", token.AccessToken)
|
||||
|
||||
newToken := oauth2.Token{
|
||||
AccessToken: "thetoken",
|
||||
}
|
||||
err = db.SetOAuth2Token(service, newToken)
|
||||
require.NoError(t, err)
|
||||
|
||||
token, err = db.GetOAuth2Token(service)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, newToken.AccessToken, token.AccessToken)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue