From 208125f5464c0def753902528b3a050a71267bcf Mon Sep 17 00:00:00 2001 From: Lucas Neiva Date: Tue, 6 Feb 2024 11:54:12 -0300 Subject: [PATCH] add acs credentials test --- test/integration/acs_credentials_test.go | 63 ++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 test/integration/acs_credentials_test.go diff --git a/test/integration/acs_credentials_test.go b/test/integration/acs_credentials_test.go new file mode 100644 index 0000000..32c101f --- /dev/null +++ b/test/integration/acs_credentials_test.go @@ -0,0 +1,63 @@ +package integration + +import ( + "context" + "log" + "testing" + "time" + + api "github.com/seamapi/go" + "github.com/seamapi/go/acs" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func test(t *testing.T) { + t.Parallel() + + seam, cleanup := newFakeSeam(t) + defer cleanup() + + systems, sErr := seam.Acs.Systems.List(context.Background(), nil) + + if sErr != nil { + log.Panic(sErr) + } + + var visionlineSystem *api.AcsSystem + + for _, s := range systems.AcsSystems { + if s.ExternalType == "visionline_system" { + visionlineSystem = s + } + } + + users, err := seam.Acs.Users.List(context.Background(), &acs.UsersListRequest{ + AcsSystemId: &visionlineSystem.AcsSystemId, + }) + + isMultiPhoneSyncCredential := true + + require.NoError(t, err) + + startsAt := time.Now() + + endsAt := time.Now().Add(24 * time.Hour) + + credentialResponse, uErr := seam.Acs.Credentials.Create(context.Background(), &acs.CredentialsCreateRequest{ + AcsUserId: users.AcsUsers[0].AcsUserId, + AccessMethod: "mobile_key", + IsMultiPhoneSyncCredential: &isMultiPhoneSyncCredential, + StartsAt: &startsAt, + EndsAt: &endsAt, + VisionlineMetadata: &acs.CredentialsCreateRequestVisionlineMetadata{ + CardFormat: acs.CredentialsCreateRequestVisionlineMetadataCardFormatRfid48.Ptr(), + }, + }) + + require.NoError(t, uErr) + assert.NotEmpty(t, credentialResponse.AcsCredential) + assert.True(t, credentialResponse.Ok) + assert.NotEmpty(t, credentialResponse.AcsCredential.StartsAt) + assert.NotEmpty(t, credentialResponse.AcsCredential.EndsAt) +}