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

Test other auth methods against fake-seam-connect #150

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
135 changes: 128 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@
},
"dependencies": {
"@seamapi/url-search-params-serializer": "^1.1.0",
"@types/jsonwebtoken": "^9.0.6",
"axios": "^1.5.0",
"axios-better-stacktrace": "^2.1.7",
"axios-retry": "^4.4.2"
},
"devDependencies": {
"@seamapi/fake-seam-connect": "^1.71.0",
"@seamapi/fake-seam-connect": "^1.72.0",
"@seamapi/types": "1.209.0",
"@types/eslint": "^8.44.2",
"@types/node": "^20.8.10",
Expand All @@ -115,6 +116,7 @@
"eslint-plugin-simple-import-sort": "^12.0.0",
"eslint-plugin-unused-imports": "^3.0.0",
"execa": "^9.2.0",
"jsonwebtoken": "^9.0.2",
"landlubber": "^2.0.0",
"nock": "^13.4.0",
"node-fetch": "^3.3.2",
Expand Down
14 changes: 11 additions & 3 deletions test/seam/connect/client-session-token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@ test('SeamHttp: updateClientSessionToken returns instance authorized with a new
const seam = SeamHttp.fromClientSessionToken(seed.seam_cst1_token, {
endpoint,
})
const { token } = await seam.clientSessions.create({

const devices = await seam.devices.list()
t.true(devices.length > 0)

const seamUsingApiKey = SeamHttp.fromApiKey(seed.seam_apikey2_token, {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seam_apikey2_token or seam_apikey1_token?

endpoint,
})

const { token } = await seamUsingApiKey.clientSessions.create({
user_identifier_key: 'some-new-user-identifier-key',
})

await seam.updateClientSessionToken(token)
const devices = await seam.devices.list()
t.is(devices.length, 0)
const devicesFromNewSession = await seam.devices.list()
t.is(devicesFromNewSession.length, 0)
})

test('SeamHttp: updateClientSessionToken fails if no existing clientSessionToken', async (t) => {
Expand Down
85 changes: 38 additions & 47 deletions test/seam/connect/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,54 +108,45 @@ test('SeamHttp: merges axios headers when creating client', async (t) => {
t.is(device.device_id, seed.august_device_1)
})

// UPSTREAM: Fake does not support personal access token.
// https://github.com/seamapi/fake-seam-connect/issues/126
test.failing(
'SeamHttpMultiWorkspace: fromClient returns instance that uses client',
async (t) => {
const { endpoint } = await getTestServer(t)
const seam = SeamHttpMultiWorkspace.fromClient(
SeamHttpMultiWorkspace.fromPersonalAccessToken('seam_at_TODO', {
endpoint,
}).client,
)
const workspaces = await seam.workspaces.list()
t.true(workspaces.length > 0)
},
)
test('SeamHttpMultiWorkspace: fromClient returns instance that uses client', async (t) => {
const { seed, endpoint } = await getTestServer(t)
const seam = SeamHttpMultiWorkspace.fromClient(
SeamHttpMultiWorkspace.fromPersonalAccessToken(seed.seam_at1_token, {
endpoint,
}).client,
)
const workspaces = await seam.workspaces.list()
t.true(workspaces.length > 0)
})

// UPSTREAM: Fake does not support personal access token.
// https://github.com/seamapi/fake-seam-connect/issues/126
test.failing(
'SeamHttpMultiWorkspace: constructor returns instance that uses client',
async (t) => {
const { endpoint } = await getTestServer(t)
const seam = new SeamHttpMultiWorkspace({
client: SeamHttpMultiWorkspace.fromPersonalAccessToken('seam_at_TODO', {
test('SeamHttpMultiWorkspace: constructor returns instance that uses client', async (t) => {
const { seed, endpoint } = await getTestServer(t)
const seam = new SeamHttpMultiWorkspace({
client: SeamHttpMultiWorkspace.fromPersonalAccessToken(
seed.seam_at1_token,
{
endpoint,
}).client,
})
const workspaces = await seam.workspaces.list()
t.true(workspaces.length > 0)
},
)
},
).client,
})
const workspaces = await seam.workspaces.list()
t.true(workspaces.length > 0)
})

// UPSTREAM: Fake does not support personal access token.
// https://github.com/seamapi/fake-seam-connect/issues/126
test.failing(
'SeamHttpMultiWorkspace: can use client to make requests',
async (t) => {
const { endpoint } = await getTestServer(t)
const seam = new SeamHttpMultiWorkspace({
client: SeamHttpMultiWorkspace.fromPersonalAccessToken('seam_at_TODO', {
test('SeamHttpMultiWorkspace: can use client to make requests', async (t) => {
const { seed, endpoint } = await getTestServer(t)
const seam = new SeamHttpMultiWorkspace({
client: SeamHttpMultiWorkspace.fromPersonalAccessToken(
seed.seam_at1_token,
{
endpoint,
}).client,
})
const {
data: { workspaces },
status,
} = await seam.client.get<WorkspacesListResponse>('/workspaces/list')
t.is(status, 200)
t.true(workspaces.length > 0)
},
)
},
).client,
})
const {
data: { workspaces },
status,
} = await seam.client.get<WorkspacesListResponse>('/workspaces/list')
t.is(status, 200)
t.true(workspaces.length > 0)
})
Loading
Loading