Skip to content

Commit

Permalink
renamed test suites
Browse files Browse the repository at this point in the history
  • Loading branch information
Ptroger committed Aug 26, 2024
1 parent 2f9ba73 commit bc8c8a9
Showing 1 changed file with 69 additions and 69 deletions.
138 changes: 69 additions & 69 deletions packages/armory-sdk/src/lib/__test__/e2e/scenarios.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const alicePrivateKey = FIXTURE.UNSAFE_PRIVATE_KEY.Alice
const carolPrivateKey = FIXTURE.UNSAFE_PRIVATE_KEY.Carol

describe('End to end scenarios', () => {
describe('rate limiting', () => {
describe('rate limiting by principal', () => {
const request: Request = {
action: Action.SIGN_TRANSACTION,
nonce: 'test-nonce',
Expand Down Expand Up @@ -219,14 +219,14 @@ describe('End to end scenarios', () => {
})
})

describe('spending limits', () => {
describe('rate limiting by groupId', () => {
const request: Request = {
action: Action.SIGN_TRANSACTION,
nonce: 'test-nonce',
transactionRequest: {
from: '0x0301e2724a40E934Cce3345928b88956901aA127',
to: '0x76d1b7f9b3F69C435eeF76a98A415332084A856F',
value: '0x429D069189E0000', // 0.3 ETH
value: '0x58D15E176280000', // 0.4 ETH
chainId: 1
},
resourceId: 'eip155:eoa:0x0301e2724a40e934cce3345928b88956901aa127'
Expand Down Expand Up @@ -275,11 +275,36 @@ describe('End to end scenarios', () => {
x: 'm5zj9v8I_UvB-15y7t7RmQXmyNmPuvAQPDdU71LRkUA',
y: 'Az5R7PGJbmKdPpK2-jmUh7xyuaOZlCIFNU4I83xy5lU'
}
},
{
userId: 'test-carol-user-uid',
id: '0x8014093787673513011ee2be28bc685a1df716abbe0d4d76173b0dbdc33d0557',
key: {
kty: 'EC',
crv: 'secp256k1',
alg: 'ES256K',
kid: '0x8014093787673513011ee2be28bc685a1df716abbe0d4d76173b0dbdc33d0557',
x: 'OA4p5YjB0XBUzMuE6qhSwcSCLDu-yf9VekwcE320fWw',
y: 'nLK5Qr_VHqZD9rVCLMHToXvdE9KuTn6w--PJ9jcpdUU'
}
}
],
tokens: [],
userGroupMembers: [],
userGroups: [],
userGroupMembers: [
{
groupId: 'treasury-group-id',
userId: 'test-bob-user-uid'
},
{
groupId: 'treasury-group-id',
userId: 'test-carol-user-uid'
}
],
userGroups: [
{
id: 'treasury-group-id'
}
],
userAccounts: [],
users: [
{
Expand All @@ -289,6 +314,10 @@ describe('End to end scenarios', () => {
{
id: 'test-bob-user-uid',
role: 'member'
},
{
id: 'test-carol-user-uid',
role: 'member'
}
],
accountGroupMembers: [],
Expand Down Expand Up @@ -319,17 +348,13 @@ describe('End to end scenarios', () => {
then: 'permit'
},
{
id: 'member-can-transfer-1-eth',
description: 'member can transfer 1 ETH',
id: 'treasury-members-can-transfer-1-eth',
description: 'treasury group members can transfer 1 ETH',
when: [
{
criterion: 'checkAction',
args: ['signTransaction']
},
{
criterion: 'checkPrincipalRole',
args: ['member']
},
{
criterion: 'checkIntentType',
args: ['transferNative']
Expand All @@ -348,7 +373,7 @@ describe('End to end scenarios', () => {
value: 86400
},
filters: {
perPrincipal: true,
userGroups: ['treasury-group-id'],
tokens: ['eip155:1/slip44:60']
}
}
Expand Down Expand Up @@ -381,7 +406,7 @@ describe('End to end scenarios', () => {
expect(response).toMatchObject({ value: expect.any(String) })
})

it('permits member bob to do a transfer', async () => {
it('permits treasury-group member bob to do a transfer', async () => {
const { authClient } = await buildAuthClient(bobPrivateKey, {
host: getAuthHost(),
clientId
Expand All @@ -391,8 +416,8 @@ describe('End to end scenarios', () => {
expect(response).toMatchObject({ value: expect.any(String) })
})

it('permits member bob to do a second transfer', async () => {
const { authClient } = await buildAuthClient(bobPrivateKey, {
it('permits treasury-group member carol to do a transfer', async () => {
const { authClient } = await buildAuthClient(carolPrivateKey, {
host: getAuthHost(),
clientId
})
Expand All @@ -401,19 +426,21 @@ describe('End to end scenarios', () => {
expect(response).toMatchObject({ value: expect.any(String) })
})

it('permits member bob to do a third transfer', async () => {
it('forbids member bob to exceed the limit', async () => {
const { authClient } = await buildAuthClient(bobPrivateKey, {
host: getAuthHost(),
clientId
})

const response = await authClient.requestAccessToken(request)
expect(response).toMatchObject({ value: expect.any(String) })
try {
await authClient.requestAccessToken(request)
} catch (error: any) {
expect(error.message).toEqual('Unauthorized')
}
})

it('forbids member bob to exceed the limit', async () => {
expect.assertions(1)
const { authClient } = await buildAuthClient(bobPrivateKey, {
it('forbids member carol to exceed the limit', async () => {
const { authClient } = await buildAuthClient(carolPrivateKey, {
host: getAuthHost(),
clientId
})
Expand All @@ -436,14 +463,14 @@ describe('End to end scenarios', () => {
})
})

describe('group rate limits', () => {
describe('spending limits', () => {
const request: Request = {
action: Action.SIGN_TRANSACTION,
nonce: 'test-nonce',
transactionRequest: {
from: '0x0301e2724a40E934Cce3345928b88956901aA127',
to: '0x76d1b7f9b3F69C435eeF76a98A415332084A856F',
value: '0x58D15E176280000', // 0.4 ETH
value: '0x429D069189E0000', // 0.3 ETH
chainId: 1
},
resourceId: 'eip155:eoa:0x0301e2724a40e934cce3345928b88956901aa127'
Expand Down Expand Up @@ -492,36 +519,11 @@ describe('End to end scenarios', () => {
x: 'm5zj9v8I_UvB-15y7t7RmQXmyNmPuvAQPDdU71LRkUA',
y: 'Az5R7PGJbmKdPpK2-jmUh7xyuaOZlCIFNU4I83xy5lU'
}
},
{
userId: 'test-carol-user-uid',
id: '0x8014093787673513011ee2be28bc685a1df716abbe0d4d76173b0dbdc33d0557',
key: {
kty: 'EC',
crv: 'secp256k1',
alg: 'ES256K',
kid: '0x8014093787673513011ee2be28bc685a1df716abbe0d4d76173b0dbdc33d0557',
x: 'OA4p5YjB0XBUzMuE6qhSwcSCLDu-yf9VekwcE320fWw',
y: 'nLK5Qr_VHqZD9rVCLMHToXvdE9KuTn6w--PJ9jcpdUU'
}
}
],
tokens: [],
userGroupMembers: [
{
groupId: 'treasury-group-id',
userId: 'test-bob-user-uid'
},
{
groupId: 'treasury-group-id',
userId: 'test-carol-user-uid'
}
],
userGroups: [
{
id: 'treasury-group-id'
}
],
userGroupMembers: [],
userGroups: [],
userAccounts: [],
users: [
{
Expand All @@ -531,10 +533,6 @@ describe('End to end scenarios', () => {
{
id: 'test-bob-user-uid',
role: 'member'
},
{
id: 'test-carol-user-uid',
role: 'member'
}
],
accountGroupMembers: [],
Expand Down Expand Up @@ -565,13 +563,17 @@ describe('End to end scenarios', () => {
then: 'permit'
},
{
id: 'treasury-members-can-transfer-1-eth',
description: 'treasury group members can transfer 1 ETH',
id: 'member-can-transfer-1-eth',
description: 'member can transfer 1 ETH',
when: [
{
criterion: 'checkAction',
args: ['signTransaction']
},
{
criterion: 'checkPrincipalRole',
args: ['member']
},
{
criterion: 'checkIntentType',
args: ['transferNative']
Expand All @@ -590,7 +592,7 @@ describe('End to end scenarios', () => {
value: 86400
},
filters: {
userGroups: ['treasury-group-id'],
perPrincipal: true,
tokens: ['eip155:1/slip44:60']
}
}
Expand Down Expand Up @@ -623,7 +625,7 @@ describe('End to end scenarios', () => {
expect(response).toMatchObject({ value: expect.any(String) })
})

it('permits treasury-group member bob to do a transfer', async () => {
it('permits member bob to do a transfer', async () => {
const { authClient } = await buildAuthClient(bobPrivateKey, {
host: getAuthHost(),
clientId
Expand All @@ -633,8 +635,8 @@ describe('End to end scenarios', () => {
expect(response).toMatchObject({ value: expect.any(String) })
})

it('permits treasury-group member carol to do a transfer', async () => {
const { authClient } = await buildAuthClient(carolPrivateKey, {
it('permits member bob to do a second transfer', async () => {
const { authClient } = await buildAuthClient(bobPrivateKey, {
host: getAuthHost(),
clientId
})
Expand All @@ -643,21 +645,19 @@ describe('End to end scenarios', () => {
expect(response).toMatchObject({ value: expect.any(String) })
})

it('forbids member bob to exceed the limit', async () => {
it('permits member bob to do a third transfer', async () => {
const { authClient } = await buildAuthClient(bobPrivateKey, {
host: getAuthHost(),
clientId
})

try {
await authClient.requestAccessToken(request)
} catch (error: any) {
expect(error.message).toEqual('Unauthorized')
}
const response = await authClient.requestAccessToken(request)
expect(response).toMatchObject({ value: expect.any(String) })
})

it('forbids member carol to exceed the limit', async () => {
const { authClient } = await buildAuthClient(carolPrivateKey, {
it('forbids member bob to exceed the limit', async () => {
expect.assertions(1)
const { authClient } = await buildAuthClient(bobPrivateKey, {
host: getAuthHost(),
clientId
})
Expand All @@ -680,7 +680,7 @@ describe('End to end scenarios', () => {
})
})

describe('group spending limits requires an approval', () => {
describe('approvals by groupId and spending limit', () => {
const request: Request = {
action: Action.SIGN_TRANSACTION,
nonce: 'test-nonce',
Expand Down

0 comments on commit bc8c8a9

Please sign in to comment.