@@ -19,26 +19,34 @@ package auth_test
19
19
20
20
import (
21
21
"encoding/json"
22
- "flag"
23
22
"io/ioutil"
24
23
"net/http"
25
24
"os"
26
25
"testing"
27
26
28
27
"github.com/arduino/arduino-cli/auth"
28
+ "github.com/stretchr/testify/require"
29
29
)
30
30
31
31
var (
32
32
testUser = os .Getenv ("TEST_USERNAME" )
33
33
testPass = os .Getenv ("TEST_PASSWORD" )
34
34
)
35
35
36
- func TestMain (m * testing.M ) {
37
- flag .Parse ()
38
- os .Exit (m .Run ())
36
+ func TestNewConfig (t * testing.T ) {
37
+ conf := auth .New ()
38
+ require .Equal (t , "https://hydra.arduino.cc/oauth2/auth" , conf .CodeURL )
39
+ require .Equal (t , "https://hydra.arduino.cc/oauth2/token" , conf .TokenURL )
40
+ require .Equal (t , "cli" , conf .ClientID )
41
+ require .Equal (t , "http://localhost:5000" , conf .RedirectURI )
42
+ require .Equal (t , "profile:core offline" , conf .Scopes )
39
43
}
40
44
41
- func TestToken (t * testing.T ) {
45
+ func TestTokenIntegration (t * testing.T ) {
46
+ if testing .Short () {
47
+ t .Skip ("skip integration test" )
48
+ }
49
+
42
50
if testUser == "" || testPass == "" {
43
51
t .Skip ("Skipped because user and pass were not provided" )
44
52
}
@@ -49,7 +57,7 @@ func TestToken(t *testing.T) {
49
57
}
50
58
51
59
// Obtain info
52
- req , err := http .NewRequest ("GET" , "https://auth .arduino.cc/v1/users/byID/me" , nil )
60
+ req , err := http .NewRequest ("GET" , "https://ddauth .arduino.cc/v1/users/byID/me" , nil )
53
61
if err != nil {
54
62
t .Fatal (err )
55
63
}
0 commit comments