@@ -2,6 +2,7 @@ package easycodefgo
2
2
3
3
import (
4
4
"encoding/json"
5
+ "log"
5
6
"testing"
6
7
7
8
"github.com/stretchr/testify/assert"
@@ -25,8 +26,7 @@ func TestSetToken(t *testing.T) {
25
26
ast := assert .New (t )
26
27
codef := & Codef {}
27
28
28
- err := setToken (SandboxClientID , SandboxClientSecret , codef .getAccessToken (TypeSandbox ))
29
- ast .NoError (err )
29
+ setToken (SandboxClientID , SandboxClientSecret , codef .getAccessToken (TypeSandbox ))
30
30
ast .NotEmpty (codef .accessToken )
31
31
}
32
32
@@ -48,8 +48,7 @@ func TestRequestProduct(t *testing.T) {
48
48
ast .Empty (res .GetData ())
49
49
50
50
// Connected ID 정상 발급 테스트
51
- err = setToken (SandboxClientID , SandboxClientSecret , & accessToken )
52
- ast .NoError (err )
51
+ setToken (SandboxClientID , SandboxClientSecret , & accessToken )
53
52
54
53
res , err = requestProduct (SandboxDomain + PathCreateAccount , accessToken , string (data ))
55
54
testExistConnectedID (ast , res )
@@ -80,6 +79,31 @@ func testExistConnectedID(ast *assert.Assertions, res *Response) {
80
79
ast .True (ok )
81
80
}
82
81
82
+ // SetToken에서 3회 요청 실패 시 빈 액세스 토큰으로 요청하게됨
83
+ // 이때 응답결과 CF-00401이 발생해야함
84
+ func TestFailSetTokenResult (t * testing.T ) {
85
+ ast := assert .New (t )
86
+ codef := & Codef {PublicKey : "public_key" }
87
+
88
+ codef .SetClientInfo ("id" , "pri" )
89
+
90
+ parameter := map [string ]interface {}{
91
+ "connectedId" : "8PQI4dQ......hKLhTnZ" ,
92
+ "organization" : "0004" ,
93
+ "identity" : "1130000627" ,
94
+ }
95
+ productURL := "/v1/kr/card/b/account/card-list" // 법인 보유카드 조회 URL
96
+ result , err := codef .RequestProduct (productURL , TypeProduct , parameter )
97
+ if err != nil {
98
+ log .Fatalln (err )
99
+ }
100
+
101
+ jsonMap := make (map [string ]interface {})
102
+ json .Unmarshal ([]byte (result ), & jsonMap )
103
+ resultData := jsonMap ["result" ].(map [string ]interface {})
104
+ ast .Equal (resultData ["code" ], "CF-00401" )
105
+ }
106
+
83
107
// ConnectedID 발급을 위한 Body 테스트 데이터 생성
84
108
func createParamForCreateConnectedID () (map [string ]interface {}, error ) {
85
109
publicKey := "MIIBIjANBgkqhkiG9w0BAQ" +
0 commit comments