File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,13 @@ package auth
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
- "github.com/cloudquery/cloudquery-api-go/config"
7
6
"io"
8
7
"net/http"
9
8
"net/url"
10
9
"os"
11
10
"time"
11
+
12
+ "github.com/cloudquery/cloudquery-api-go/config"
12
13
)
13
14
14
15
const (
@@ -44,6 +45,10 @@ type Token struct {
44
45
Value string
45
46
}
46
47
48
+ func (t Token ) String () string {
49
+ return t .Value
50
+ }
51
+
47
52
type TokenClient struct {
48
53
url string
49
54
apiKey string
Original file line number Diff line number Diff line change @@ -3,12 +3,13 @@ package auth
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
- "github.com/stretchr/testify/require"
7
6
"net/http"
8
7
"net/http/httptest"
9
8
"os"
10
9
"testing"
11
10
"time"
11
+
12
+ "github.com/stretchr/testify/require"
12
13
)
13
14
14
15
func TestRefreshToken_RoundTrip (t * testing.T ) {
@@ -39,6 +40,12 @@ func TestRefreshToken_Removal(t *testing.T) {
39
40
require .Error (t , err )
40
41
}
41
42
43
+ func TestToken_Stringer (t * testing.T ) {
44
+ token := Token {Type : BearerToken , Value : "my_token" }
45
+ out := fmt .Sprintf ("Bearer %s" , token )
46
+ require .Equal (t , "Bearer my_token" , out )
47
+ }
48
+
42
49
func TestTokenClient_EnvironmentVariable (t * testing.T ) {
43
50
reset := overrideEnvironmentVariable (t , EnvVarCloudQueryAPIKey , "my_token" )
44
51
defer reset ()
You can’t perform that action at this time.
0 commit comments