Skip to content

Commit c1d8426

Browse files
committed
test: add aksk usage
1 parent 8bf7744 commit c1d8426

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

codecov.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
ignore:
22
- "**/*.gen.go"
3+
- "examples"

integrationtest/aksk_test.go

+29
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,35 @@ func AkSkSpec(ctx context.Context, urlStr string) func(c convey.C) {
141141
convey.ShouldHaveLength(result.JSON200, 6)
142142
})
143143
})
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.ParseCreateRepositoryResponse(resp)
157+
convey.So(err, convey.ShouldBeNil)
158+
convey.ShouldEqual(user.JSON201.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+
_, err = api.NewClient(urlStr+apiimpl.APIV1Prefix, api.AkSkOption(aksk.AccessKey, "fakesk"))
165+
convey.So(err, convey.ShouldNotBeNil)
166+
})
167+
168+
c.Convey("ak not exit", func(c convey.C) {
169+
_, err := api.NewClient(urlStr+apiimpl.APIV1Prefix, api.AkSkOption("fakesk", "fakesk"))
170+
convey.So(err, convey.ShouldNotBeNil)
171+
})
172+
})
144173
}
145174
}
146175

0 commit comments

Comments
 (0)