Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add acs credentials test #28

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions test/integration/acs_credentials_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
Loading