gds-api-adapters 103.4.0 → 103.4.2
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.
- checksums.yaml +4 -4
- data/lib/gds_api/test_helpers/asset_manager.rb +55 -5
- data/lib/gds_api/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: ed240c19e93a1fedbe00ab099ed8f3164db3b9c45b4171142fe0dd1ed93b2b7b
|
|
4
|
+
data.tar.gz: 3b18e6d45cb3ae896445f21b53b371311d86602283488b5425bfa7ed7d129a65
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a7d25c347beff6b39e8964643aa69570b4ae6c23ce6ed46cbbbd6bdd040ca07444e57ddc40cbd8c192369685f8d081ee47a2c0ec90f241c660f195901687219b
|
|
7
|
+
data.tar.gz: 1a3b9c119e6780dc32101053873311ce13258cc8a5b679c01e017bda5a1939ec2bf915341d8dbebc4a91e1263e3e651a56ada7d196a22068ce1ded9262550856
|
|
@@ -24,9 +24,16 @@ module GdsApi
|
|
|
24
24
|
def stub_asset_manager_has_an_asset(id, atts, filename = "")
|
|
25
25
|
response = atts.merge("_response_info" => { "status" => "ok" })
|
|
26
26
|
|
|
27
|
+
stub_asset_manager_request_to_get_asset(id, response)
|
|
28
|
+
stub_asset_manager_request_to_asset_media(id, filename)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def stub_asset_manager_request_to_get_asset(id, response)
|
|
27
32
|
stub_request(:get, "#{ASSET_MANAGER_ENDPOINT}/assets/#{id}")
|
|
28
33
|
.to_return(body: response.to_json, status: 200)
|
|
34
|
+
end
|
|
29
35
|
|
|
36
|
+
def stub_asset_manager_request_to_asset_media(id, filename)
|
|
30
37
|
stub_request(:get, "#{ASSET_MANAGER_ENDPOINT}/media/#{id}/#{filename}")
|
|
31
38
|
.to_return(body: "Some file content", status: 200)
|
|
32
39
|
end
|
|
@@ -45,20 +52,24 @@ module GdsApi
|
|
|
45
52
|
.to_return(body: response.to_json, status: 404)
|
|
46
53
|
end
|
|
47
54
|
|
|
55
|
+
def stub_asset_manager_get_asset_forbidden(id)
|
|
56
|
+
stub_request(:get, "#{ASSET_MANAGER_ENDPOINT}/assets/#{id}").to_return(status: 403)
|
|
57
|
+
end
|
|
58
|
+
|
|
48
59
|
# This can take a string of an exact url or a hash of options
|
|
49
60
|
#
|
|
50
61
|
# with a string:
|
|
51
|
-
# `
|
|
62
|
+
# `stub_asset_manager_create_asset("https://asset-manager/media/619ce797-b415-42e5-b2b1-2ffa0df52302/file.jpg")`
|
|
52
63
|
#
|
|
53
64
|
# with a hash:
|
|
54
|
-
# `
|
|
65
|
+
# `stub_asset_manager_create_asset(id: "20d04259-e3ae-4f71-8157-e6c843096e96", filename: "file.jpg")`
|
|
55
66
|
# which would return a file url of "https://asset-manager/media/20d04259-e3ae-4f71-8157-e6c843096e96/file.jpg"
|
|
56
67
|
#
|
|
57
68
|
# with no argument
|
|
58
69
|
#
|
|
59
|
-
# `
|
|
70
|
+
# `stub_asset_manager_create_asset`
|
|
60
71
|
# which would return a file url of "https://asset-manager/media/0053adbf-0737-4923-9d8a-8180f2c723af/0d19136c4a94f07"
|
|
61
|
-
def
|
|
72
|
+
def stub_asset_manager_create_asset(response_url = {}, response_body = {})
|
|
62
73
|
stub_request(:post, "#{ASSET_MANAGER_ENDPOINT}/assets").to_return do
|
|
63
74
|
if response_url.is_a?(String)
|
|
64
75
|
file_url = response_url
|
|
@@ -70,10 +81,28 @@ module GdsApi
|
|
|
70
81
|
|
|
71
82
|
file_url = "#{ASSET_MANAGER_ENDPOINT}/media/#{options[:id]}/#{options[:filename]}"
|
|
72
83
|
end
|
|
73
|
-
{ body:
|
|
84
|
+
{ body: response_body.merge(file_url:).to_json, status: 200 }
|
|
74
85
|
end
|
|
75
86
|
end
|
|
76
87
|
|
|
88
|
+
def stub_asset_manager_receives_an_asset(response_url = {})
|
|
89
|
+
warn <<~WARNING
|
|
90
|
+
stub_asset_manager_receives_an_asset is deprecated and will be removed
|
|
91
|
+
in a future version of gds-api-adapters. Replace calls to this method with
|
|
92
|
+
stub_asset_manager_create_asset.
|
|
93
|
+
WARNING
|
|
94
|
+
|
|
95
|
+
stub_asset_manager_create_asset(response_url)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def stub_asset_manager_create_asset_too_large
|
|
99
|
+
stub_request(:post, "#{ASSET_MANAGER_ENDPOINT}/assets").to_return(status: 413)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def stub_asset_manager_create_asset_unprocessable(body = "")
|
|
103
|
+
stub_request(:post, "#{ASSET_MANAGER_ENDPOINT}/assets").to_return(body:, status: 422)
|
|
104
|
+
end
|
|
105
|
+
|
|
77
106
|
def stub_asset_manager_upload_failure
|
|
78
107
|
stub_request(:post, "#{ASSET_MANAGER_ENDPOINT}/assets").to_return(status: 500)
|
|
79
108
|
end
|
|
@@ -83,6 +112,22 @@ module GdsApi
|
|
|
83
112
|
.to_return(body: body.to_json, status: 200)
|
|
84
113
|
end
|
|
85
114
|
|
|
115
|
+
def stub_asset_manager_update_asset_forbidden(asset_id)
|
|
116
|
+
stub_request(:put, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}").to_return(status: 403)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def stub_asset_manager_update_asset_not_found(asset_id)
|
|
120
|
+
stub_request(:put, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}").to_return(status: 404)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def stub_asset_manager_update_asset_too_large(asset_id)
|
|
124
|
+
stub_request(:put, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}").to_return(status: 413)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def stub_asset_manager_update_asset_unprocessable(asset_id, body = "")
|
|
128
|
+
stub_request(:put, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}").to_return(body:, status: 422)
|
|
129
|
+
end
|
|
130
|
+
|
|
86
131
|
def stub_asset_manager_update_asset_failure(asset_id)
|
|
87
132
|
stub_request(:put, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}").to_return(status: 500)
|
|
88
133
|
end
|
|
@@ -92,6 +137,11 @@ module GdsApi
|
|
|
92
137
|
.to_return(body: body.to_json, status: 200)
|
|
93
138
|
end
|
|
94
139
|
|
|
140
|
+
def stub_asset_manager_delete_asset_forbidden(asset_id)
|
|
141
|
+
stub_request(:delete, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}")
|
|
142
|
+
.to_return(status: 403)
|
|
143
|
+
end
|
|
144
|
+
|
|
95
145
|
def stub_asset_manager_delete_asset_missing(asset_id)
|
|
96
146
|
stub_request(:delete, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}")
|
|
97
147
|
.to_return(status: 404)
|
data/lib/gds_api/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gds-api-adapters
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 103.4.
|
|
4
|
+
version: 103.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GOV.UK Dev
|
|
@@ -412,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
412
412
|
- !ruby/object:Gem::Version
|
|
413
413
|
version: '0'
|
|
414
414
|
requirements: []
|
|
415
|
-
rubygems_version: 4.0.
|
|
415
|
+
rubygems_version: 4.0.19
|
|
416
416
|
specification_version: 4
|
|
417
417
|
summary: Adapters to work with GDS APIs
|
|
418
418
|
test_files: []
|