-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers_test.go
50 lines (40 loc) · 1.24 KB
/
helpers_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package credentials_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/theopenlane/newman/credentials"
)
func TestParseCredentials(t *testing.T) {
credentialsJSON := []byte(`{
"installed": {
"client_id": "your-client-id",
"project_id": "your-project-id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "your-client-secret",
"redirect_uris": ["urn:ietf:wg:oauth:2.0:oob","http://localhost"]
}
}`)
_, err := credentials.ParseCredentials(credentialsJSON)
assert.NoError(t, err)
}
func TestParseToken(t *testing.T) {
tokenJSON := []byte(`{
"access_token": "mock_access_token",
"token_type": "Bearer",
"expiry": "2023-10-02T15:00:00Z"
}`)
_, err := credentials.ParseToken(tokenJSON)
assert.NoError(t, err)
}
func TestParseCredentialsInvalidJson(t *testing.T) {
credentialsJSON := []byte(`{invalid_json}`)
_, err := credentials.ParseCredentials(credentialsJSON)
assert.Error(t, err)
}
func TestParseTokenInvalidJson(t *testing.T) {
tokenJSON := []byte(`{invalid_json}`)
_, err := credentials.ParseToken(tokenJSON)
assert.Error(t, err)
}