@defra-fish/connectors-lib 1.61.0-rc.16 → 1.61.0-rc.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra-fish/connectors-lib",
3
- "version": "1.61.0-rc.16",
3
+ "version": "1.61.0-rc.18",
4
4
  "description": "Shared connectors",
5
5
  "type": "module",
6
6
  "engines": {
@@ -46,5 +46,5 @@
46
46
  "node-fetch": "^2.7.0",
47
47
  "redlock": "^4.2.0"
48
48
  },
49
- "gitHead": "a4d24d55c8279ed8fad6436a48312f8542adfada"
49
+ "gitHead": "e6a140250c115a25e37da3f1639e83df2e6ca886"
50
50
  }
@@ -21,13 +21,38 @@ describe('AWS Special cases', () => {
21
21
  })
22
22
  )
23
23
  })
24
+
25
+ it('exports ListObjectsV2Command from S3 SDK', () => {
26
+ const { ListObjectsV2Command } = AWS()
27
+ expect(ListObjectsV2Command).toBeDefined()
28
+ })
29
+
30
+ describe('AWS connectors for S3Client', () => {
31
+ it('has region set to eu-west-2', async () => {
32
+ const { s3 } = AWS()
33
+ const region = await s3.config.region()
34
+ expect(region).toBe('eu-west-2')
35
+ })
36
+
37
+ it('sets forcePathStyle to true when endpoint is defined', () => {
38
+ Config.aws.s3.endpoint = 'http://localhost:8080'
39
+ const { s3 } = AWS()
40
+ expect(s3.config.forcePathStyle).toBe(true)
41
+ delete Config.aws.s3.endpoint
42
+ })
43
+
44
+ it('does not set forcePathStyle when no endpoint is defined', () => {
45
+ const { s3 } = AWS()
46
+ expect(s3.config.forcePathStyle).not.toBe(true)
47
+ })
48
+ })
24
49
  })
25
50
 
26
51
  describe.each`
27
52
  name | clientName | configName | expectedAPIVersion
28
53
  ${'ddb'} | ${'DynamoDB'} | ${''} | ${'2012-08-10'}
29
54
  ${'sqs'} | ${'SQS'} | ${''} | ${'2012-11-05'}
30
- ${'s3'} | ${'S3'} | ${''} | ${'2006-03-01'}
55
+ ${'s3'} | ${'S3Client'} | ${'s3'} | ${'2006-03-01'}
31
56
  ${'secretsManager'} | ${'SecretsManager'} | ${'secretsManager'} | ${'2017-10-17'}
32
57
  ${'docClient'} | ${'DynamoDBDocument'} | ${'dynamodb'} | ${'2012-08-10'}
33
58
  `('AWS connectors for $clientName', ({ name, clientName, configName, expectedAPIVersion }) => {
@@ -706,52 +706,4 @@ describe('sales-api-connector', () => {
706
706
  })
707
707
  })
708
708
  })
709
-
710
- describe('linkRecurringPayments', () => {
711
- describe.each([
712
- ['existing-recurring-payment-id', 'agreement-id'],
713
- ['abc-123', 'def-456']
714
- ])("Processing payment for transaction id '%s'", (existingRecurringPaymentId, agreementId) => {
715
- beforeEach(() => {
716
- fetch.mockReturnValue({
717
- ok: true,
718
- status: 200,
719
- statusText: 'OK',
720
- text: async () => JSON.stringify({ existingRecurringPaymentId, agreementId })
721
- })
722
- })
723
-
724
- it('calls the endpoint with the correct parameters', async () => {
725
- await salesApi.linkRecurringPayments(existingRecurringPaymentId, agreementId)
726
-
727
- expect(fetch).toHaveBeenCalledWith(`http://0.0.0.0:4000/linkRecurringPayments/${existingRecurringPaymentId}/${agreementId}`, {
728
- method: 'get',
729
- headers: expect.any(Object),
730
- timeout: 20000
731
- })
732
- })
733
-
734
- it('returns the expected response data', async () => {
735
- const processedResult = await salesApi.linkRecurringPayments(existingRecurringPaymentId, agreementId)
736
-
737
- expect(processedResult).toEqual({ existingRecurringPaymentId, agreementId })
738
- })
739
- })
740
-
741
- it('throws an error on non-2xx response', async () => {
742
- fetch.mockReturnValue({
743
- ok: false,
744
- status: 500,
745
- statusText: 'Internal Server Error',
746
- text: async () => 'Server Error'
747
- })
748
-
749
- await expect(salesApi.linkRecurringPayments('existing-recurring-payment-id', 'agreement-id')).rejects.toThrow('Internal Server Error')
750
- expect(fetch).toHaveBeenCalledWith('http://0.0.0.0:4000/linkRecurringPayments/existing-recurring-payment-id/agreement-id', {
751
- method: 'get',
752
- headers: expect.any(Object),
753
- timeout: 20000
754
- })
755
- })
756
- })
757
709
  })
package/src/aws.js CHANGED
@@ -2,7 +2,7 @@ import Config from './config.js'
2
2
  import { createDocumentClient } from './documentclient-decorator.js'
3
3
  import { DynamoDB } from '@aws-sdk/client-dynamodb'
4
4
  import { SQS } from '@aws-sdk/client-sqs'
5
- import { S3 } from '@aws-sdk/client-s3'
5
+ import { S3Client, ListObjectsV2Command } from '@aws-sdk/client-s3'
6
6
  import { SecretsManager } from '@aws-sdk/client-secrets-manager'
7
7
 
8
8
  export default function () {
@@ -26,7 +26,8 @@ export default function () {
26
26
  endpoint: Config.aws.sqs.endpoint
27
27
  })
28
28
  }),
29
- s3: new S3({
29
+ s3: new S3Client({
30
+ region: 'eu-west-2',
30
31
  apiVersion: '2006-03-01',
31
32
  ...(Config.aws.s3.endpoint && {
32
33
  endpoint: Config.aws.s3.endpoint,
@@ -38,6 +39,7 @@ export default function () {
38
39
  ...(Config.aws.secretsManager.endpoint && {
39
40
  endpoint: Config.aws.secretsManager.endpoint
40
41
  })
41
- })
42
+ }),
43
+ ListObjectsV2Command
42
44
  }
43
45
  }
@@ -308,15 +308,3 @@ export const preparePermissionDataForRenewal = async referenceNumber =>
308
308
  export const processRPResult = async (transactionId, paymentId, createdDate) => {
309
309
  return exec2xxOrThrow(call(new URL(`/processRPResult/${transactionId}/${paymentId}/${createdDate}`, urlBase), 'get'))
310
310
  }
311
-
312
- /**
313
- * Link an old RecurringPayment to its replacement
314
- *
315
- * @param existingRecurringPaymentId
316
- * @param agreementId
317
- * @returns {Promise<*>}
318
- * @throws on a non-2xx response
319
- */
320
- export const linkRecurringPayments = async (existingRecurringPaymentId, agreementId) => {
321
- return exec2xxOrThrow(call(new URL(`/linkRecurringPayments/${existingRecurringPaymentId}/${agreementId}`, urlBase), 'get'))
322
- }