Skip to content

Commit

Permalink
feat: tenanted quotes - first iteration with dummy tenant
Browse files Browse the repository at this point in the history
  • Loading branch information
sanducb committed Dec 10, 2024
1 parent ea7e660 commit 8ef2027
Show file tree
Hide file tree
Showing 45 changed files with 497 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsHost}}/quotes
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/quotes
body: json
auth: none
}
Expand All @@ -17,7 +17,7 @@ headers {
body:json {
{
"walletAddress": "{{senderWalletAddress}}",
"receiver": "{{receiverOpenPaymentsHost}}/incoming-payments/{{incomingPaymentId}}",
"receiver": "{{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments/{{incomingPaymentId}}",
"method": "ilp"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsHost}}/quotes
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/quotes
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{senderOpenPaymentsHost}}/quotes/{{quoteId}}
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/quotes/{{quoteId}}
body: none
auth: none
}
Expand Down
13 changes: 10 additions & 3 deletions localenv/mock-account-servicing-entity/generated/graphql.ts

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

22 changes: 22 additions & 0 deletions packages/backend/migrations/20241203140018_seed_tenant_operator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex('tenants').insert({
id: '8e1db008-ab2f-4f1d-8c44-593354084100',
email: 'admin@example.com',
publicName: 'Super tenant',
apiSecret: 'secret'
})
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex('tenants')
.where('id', '8e1db008-ab2f-4f1d-8c44-593354084100')
.del()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.schema.alterTable('quotes', function (table) {
// TODO update default value
table.uuid('tenantId').notNullable()
table.foreign('tenantId').references('tenants.id').onDelete('CASCADE')
})
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.schema.alterTable('quotes', function (table) {
table.dropForeign('tenantId')
table.dropColumn('tenantId')
})
}
66 changes: 65 additions & 1 deletion packages/backend/src/graphql/generated/graphql.schema.json

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

13 changes: 10 additions & 3 deletions packages/backend/src/graphql/generated/graphql.ts

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

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Payment', (): void => {
let deps: IocContract<AppServices>
let appContainer: TestContainer
let asset: Asset
let tenantId: string

beforeAll(async (): Promise<void> => {
deps = initIocContainer(Config)
Expand All @@ -31,6 +32,7 @@ describe('Payment', (): void => {

beforeEach(async (): Promise<void> => {
asset = await createAsset(deps)
tenantId = '8e1db008-ab2f-4f1d-8c44-593354084100'
})

afterEach(async (): Promise<void> => {
Expand All @@ -55,6 +57,7 @@ describe('Payment', (): void => {

const client = 'client-test'
const outgoingPayment = await createOutgoingPayment(deps, {
tenantId,
walletAddressId: outWalletAddressId,
client: client,
method: 'ilp',
Expand Down Expand Up @@ -161,6 +164,7 @@ describe('Payment', (): void => {

const client = 'client-test-type-wallet-address'
const outgoingPayment = await createOutgoingPayment(deps, {
tenantId,
walletAddressId: outWalletAddressId,
client: client,
method: 'ilp',
Expand All @@ -171,6 +175,7 @@ describe('Payment', (): void => {
assetId: asset.id
})
await createOutgoingPayment(deps, {
tenantId,
walletAddressId: outWalletAddressId2,
client: client,
method: 'ilp',
Expand Down
6 changes: 6 additions & 0 deletions packages/backend/src/graphql/resolvers/liquidity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1742,11 +1742,13 @@ describe('Liquidity Resolvers', (): void => {
)

describe('Event Liquidity', (): void => {
let tenantId: string
let walletAddress: WalletAddress
let incomingPayment: IncomingPayment
let payment: OutgoingPayment

beforeEach(async (): Promise<void> => {
tenantId = '8e1db008-ab2f-4f1d-8c44-593354084100'
walletAddress = await createWalletAddress(deps)
const walletAddressId = walletAddress.id
incomingPayment = await createIncomingPayment(deps, {
Expand All @@ -1759,6 +1761,7 @@ describe('Liquidity Resolvers', (): void => {
expiresAt: new Date(Date.now() + 60 * 1000)
})
payment = await createOutgoingPayment(deps, {
tenantId,
walletAddressId,
method: 'ilp',
receiver: `${Config.openPaymentsUrl}/incoming-payments/${uuid()}`,
Expand Down Expand Up @@ -2152,11 +2155,13 @@ describe('Liquidity Resolvers', (): void => {
})

describe('Payment Liquidity', (): void => {
let tenantId: string
let walletAddress: WalletAddress
let incomingPayment: IncomingPayment
let outgoingPayment: OutgoingPayment

beforeEach(async (): Promise<void> => {
tenantId = '8e1db008-ab2f-4f1d-8c44-593354084100'
walletAddress = await createWalletAddress(deps)
const walletAddressId = walletAddress.id
incomingPayment = await createIncomingPayment(deps, {
Expand All @@ -2169,6 +2174,7 @@ describe('Liquidity Resolvers', (): void => {
expiresAt: new Date(Date.now() + 60 * 1000)
})
outgoingPayment = await createOutgoingPayment(deps, {
tenantId,
walletAddressId,
method: 'ilp',
receiver: `${
Expand Down
Loading

0 comments on commit 8ef2027

Please sign in to comment.