forked from G-Core/gcorelabscloud-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixtures.go
37 lines (31 loc) · 842 Bytes
/
fixtures.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
package testing
import (
"encoding/json"
"fmt"
"net/http"
"testing"
fake "github.com/alexandrpaliy/gcorelabscloud-go/testhelper/client"
"github.com/alexandrpaliy/gcorelabscloud-go/gcore/identity/tokens"
"github.com/alexandrpaliy/gcorelabscloud-go/testhelper"
)
// TokenOutput is a sample response to a AccessToken call.
var TokenOutput = fmt.Sprintf(`
{
"access": "%s",
"refresh": "%s"
}`, fake.AccessToken,
fake.RefreshToken,
)
var expectedToken = tokens.Token{
Access: fake.AccessToken,
Refresh: fake.RefreshToken,
}
func getTokenResult(t *testing.T) tokens.TokenResult {
result := tokens.TokenResult{}
result.Header = http.Header{
"Authorization": []string{fmt.Sprintf("Bearer %s", fake.AccessToken)},
}
err := json.Unmarshal([]byte(TokenOutput), &result.Body)
testhelper.AssertNoErr(t, err)
return result
}