@@ -141,6 +141,43 @@ func AkSkSpec(ctx context.Context, urlStr string) func(c convey.C) {
141
141
convey .ShouldHaveLength (result .JSON200 , 6 )
142
142
})
143
143
})
144
+
145
+ c .Convey ("aksk usage" , func (c convey.C ) {
146
+ c .Convey ("success" , func (c convey.C ) {
147
+ aksk , err := createAksk (ctx , client )
148
+ convey .So (err , convey .ShouldBeNil )
149
+
150
+ cli , err := api .NewClient (urlStr + apiimpl .APIV1Prefix , api .AkSkOption (aksk .AccessKey , aksk .SecretKey ))
151
+ convey .So (err , convey .ShouldBeNil )
152
+
153
+ resp , err := cli .GetUserInfo (ctx )
154
+ convey .So (err , convey .ShouldBeNil )
155
+
156
+ user , err := api .ParseGetUserInfoResponse (resp )
157
+ convey .So (err , convey .ShouldBeNil )
158
+ convey .ShouldEqual (user .JSON200 .Name , userName )
159
+ })
160
+ c .Convey ("wrong sk" , func (c convey.C ) {
161
+ aksk , err := createAksk (ctx , client )
162
+ convey .So (err , convey .ShouldBeNil )
163
+
164
+ client , err := api .NewClient (urlStr + apiimpl .APIV1Prefix , api .AkSkOption (aksk .AccessKey , "fakesk" ))
165
+ convey .So (err , convey .ShouldBeNil )
166
+
167
+ resp , err := client .GetUserInfo (ctx )
168
+ convey .So (err , convey .ShouldBeNil )
169
+ convey .ShouldEqual (resp .StatusCode , http .StatusUnauthorized )
170
+ })
171
+
172
+ c .Convey ("ak not exit" , func (c convey.C ) {
173
+ client , err := api .NewClient (urlStr + apiimpl .APIV1Prefix , api .AkSkOption ("fakesk" , "fakesk" ))
174
+ convey .So (err , convey .ShouldBeNil )
175
+
176
+ resp , err := client .GetUserInfo (ctx )
177
+ convey .So (err , convey .ShouldBeNil )
178
+ convey .ShouldEqual (resp .StatusCode , http .StatusUnauthorized )
179
+ })
180
+ })
144
181
}
145
182
}
146
183
0 commit comments