defra_ruby_mocks 4.2.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -2
- data/app/controllers/defra_ruby_mocks/govpay_controller.rb +1 -1
- data/app/services/defra_ruby_mocks/aws_bucket_service.rb +16 -8
- data/app/services/defra_ruby_mocks/govpay_refund_details_service.rb +1 -1
- data/app/services/defra_ruby_mocks/govpay_request_refund_service.rb +1 -1
- data/lib/defra_ruby_mocks/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a608d402c9667f9aef72c67f4ae1edf115d0385b4315e37e6c926d1c79d92958
|
4
|
+
data.tar.gz: 2d8f253849caf74c2486777e82f2c5406bde65725d14078271452df3afdaab98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4550088184172df4cf64516baa91a60ae1f6fd496cb2a3d8dbbe9c3375dc1afc73e2dbea191217d059c34773d73de56cc4b5c8c854a1b1cb47869ca8cc8bd22
|
7
|
+
data.tar.gz: ec7ca0077154ced7847aa76947403b2a994a7b3f2460bc1451755abc4e31f16ed30407ca1c60588f1d04f66c28b9b075c6d64abdcf7021b7ad18775323d85faf
|
data/README.md
CHANGED
@@ -171,10 +171,10 @@ This Govpay mock replicates those 2 interactions with the following url
|
|
171
171
|
|
172
172
|
#### Configuration
|
173
173
|
|
174
|
-
In order to use the govpay mock you'll need to provide additional configuration details
|
174
|
+
In order to use the govpay mock you'll need to provide additional configuration details:
|
175
175
|
|
176
176
|
```ruby
|
177
|
-
|
177
|
+
config/initializers/defra_ruby_mocks.rb
|
178
178
|
require "defra_ruby_mocks"
|
179
179
|
|
180
180
|
DefraRubyMocks.configure do |config|
|
@@ -184,6 +184,26 @@ end
|
|
184
184
|
|
185
185
|
The domain is used when generating the URL we tell the app to redirect users to. As this is just an engine and not a standalone service, we need to tell it what domain it is running from.
|
186
186
|
|
187
|
+
You'll also need to provide AWS configuration details for the mocks, for example:
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
require "defra_ruby/aws"
|
191
|
+
|
192
|
+
DefraRuby::Aws.configure do |c|
|
193
|
+
govpay_mocks_bucket = {
|
194
|
+
name: ENV.fetch("AWS_DEFRA_RUBY_MOCKS_BUCKET", nil),
|
195
|
+
region: ENV.fetch("AWS_REGION", nil),
|
196
|
+
credentials: {
|
197
|
+
access_key_id: ENV.fetch("AWS_DEFRA_RUBY_MOCKS_ACCESS_KEY_ID", nil),
|
198
|
+
secret_access_key: ENV.fetch("AWS_DEFRA_RUBY_MOCKS_SECRET_ACCESS_KEY", nil)
|
199
|
+
},
|
200
|
+
encrypt_with_kms: ENV.fetch("AWS_DEFRA_RUBY_MOCKS_ENCRYPT_WITH_KMS", nil)
|
201
|
+
}
|
202
|
+
|
203
|
+
c.buckets = [govpay_mocks_bucket]
|
204
|
+
end
|
205
|
+
```
|
206
|
+
|
187
207
|
```ruby
|
188
208
|
mount DefraRubyMocks::Engine => "/mocks"
|
189
209
|
```
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "aws-sdk-s3"
|
3
4
|
require "defra_ruby/aws"
|
4
5
|
|
5
6
|
module DefraRubyMocks
|
@@ -18,6 +19,7 @@ module DefraRubyMocks
|
|
18
19
|
def write(bucket_name, file_name, content)
|
19
20
|
@bucket_name = bucket_name
|
20
21
|
@file_name = file_name
|
22
|
+
Rails.logger.debug ":::::: mocks writing to S3"
|
21
23
|
|
22
24
|
write_temp_file(content)
|
23
25
|
|
@@ -27,12 +29,18 @@ module DefraRubyMocks
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def read(bucket_name, file_name)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
@bucket_name = bucket_name
|
33
|
+
@file_name = file_name
|
34
|
+
Rails.logger.debug ":::::: mocks reading from S3"
|
35
|
+
|
36
|
+
s3 = Aws::S3::Client.new(
|
37
|
+
region: ENV.fetch("AWS_REGION", nil),
|
38
|
+
credentials: Aws::Credentials.new(
|
39
|
+
ENV.fetch("AWS_DEFRA_RUBY_MOCKS_ACCESS_KEY_ID", nil),
|
40
|
+
ENV.fetch("AWS_DEFRA_RUBY_MOCKS_SECRET_ACCESS_KEY", nil)
|
41
|
+
)
|
42
|
+
)
|
43
|
+
s3.get_object(bucket: bucket_name, key: file_name).body.read
|
36
44
|
end
|
37
45
|
|
38
46
|
private
|
@@ -42,12 +50,12 @@ module DefraRubyMocks
|
|
42
50
|
end
|
43
51
|
|
44
52
|
def write_temp_file(content)
|
45
|
-
Rails.logger.
|
53
|
+
Rails.logger.debug ":::::: mocks creating temp file for #{content}"
|
46
54
|
File.write(temp_filepath, content)
|
47
55
|
end
|
48
56
|
|
49
57
|
def load_temp_file_to_s3
|
50
|
-
Rails.logger.
|
58
|
+
Rails.logger.debug ":::::: mocks loading temp file to S3 bucket #{bucket_name}"
|
51
59
|
|
52
60
|
result = nil
|
53
61
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defra_ruby_mocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Defra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|