-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.go
90 lines (67 loc) · 2.17 KB
/
config.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright (c) 2022 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.
package integration
import (
"fmt"
"os"
"time"
"github.com/AccelByte/accelbyte-go-sdk/iam-sdk/pkg/iamclientmodels"
"github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository"
"github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/utils/connectionutils"
)
/*
Please set your client_id and client_secret in to the env before run the test
*/
var (
NamespaceTest = os.Getenv("AB_NAMESPACE")
)
type ConnectionManagerImpl struct {
}
var wsConn *connectionutils.WSConnection
func (connManager *ConnectionManagerImpl) Save(conn *connectionutils.WSConnection) {
wsConn = conn
}
func (connManager *ConnectionManagerImpl) Get() *connectionutils.WSConnection {
return wsConn
}
func (connManager *ConnectionManagerImpl) Close() error {
if wsConn == nil {
return fmt.Errorf("no websocket connection can be closed")
}
return wsConn.Conn.Close()
}
// ------------------------------------- section for phantauth token repo -----------------------------------
type TokenRepositoryPhantAuthImpl struct {
IssuedTime *time.Time
AccessToken *iamclientmodels.OauthmodelTokenResponseV3
}
type ConfigRepositoryPhantAuthImpl struct {
}
func (c *ConfigRepositoryPhantAuthImpl) GetClientId() string {
return "test.client"
}
func (c *ConfigRepositoryPhantAuthImpl) GetClientSecret() string {
return "UTBcWwt5"
}
func (c *ConfigRepositoryPhantAuthImpl) GetJusticeBaseUrl() string {
return os.Getenv("AB_PHANTAUTH_BASE_URL")
}
func (t *TokenRepositoryPhantAuthImpl) Store(accessToken interface{}) error {
convertedToken, err := repository.ConvertInterfaceToModel(accessToken)
if err != nil {
return err
}
t.AccessToken = convertedToken
return nil
}
func (t *TokenRepositoryPhantAuthImpl) GetToken() (*iamclientmodels.OauthmodelTokenResponseV3, error) {
return t.AccessToken, nil
}
func (t *TokenRepositoryPhantAuthImpl) RemoveToken() error {
t.AccessToken = &iamclientmodels.OauthmodelTokenResponseV3{}
return nil
}
func (t *TokenRepositoryPhantAuthImpl) TokenIssuedTimeUTC() time.Time {
return *t.IssuedTime
}