stitches 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +77 -12
- data/.ruby-version +1 -1
- data/lib/stitches/valid_mime_type.rb +11 -4
- data/lib/stitches/version.rb +1 -1
- data/spec/valid_mime_type_spec.rb +16 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1224843bf19c711e4058e54025f2507fe4dd0085fb5afdd57d5d383bf8d1b03e
|
4
|
+
data.tar.gz: 8f2c1f7f053d711e6419b8e19c23cc123ce7164513b7cb3978091d081612001a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f16b168bf89994f06816661fb0dda066c248a3c55a22bdeebebf32d4a0e784368b41a460f25a84c9e0c4a694b37d372a24cf739171191925f31df7df7a562be6
|
7
|
+
data.tar.gz: 053d0ae0e44945437218bc87206038029065b0ff8b6f8321bbad8b878024bddb16432b0f23136286e6019805a716d541a37a2d5382479b9216a9cde0104bf5d9
|
data/.circleci/config.yml
CHANGED
@@ -3,9 +3,33 @@
|
|
3
3
|
---
|
4
4
|
version: 2
|
5
5
|
jobs:
|
6
|
+
generate-and-push-docs:
|
7
|
+
docker:
|
8
|
+
- image: circleci/ruby:2.7.2
|
9
|
+
auth:
|
10
|
+
username: "$DOCKERHUB_USERNAME"
|
11
|
+
password: "$DOCKERHUB_PASSWORD"
|
12
|
+
steps:
|
13
|
+
- checkout
|
14
|
+
- run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
|
15
|
+
- run: bundle install --full-index
|
16
|
+
- run:
|
17
|
+
name: Generate documentation
|
18
|
+
command: ' if [[ $(bundle exec rake -T docs:generate:custom) ]]; then echo
|
19
|
+
"Generating docs using rake task docs:generate:custom" ; bundle exec rake
|
20
|
+
docs:generate:custom ; elif [[ $(bundle exec rake -T docs:generate) ]];
|
21
|
+
then echo "Generating docs using rake task docs:generate" ; bundle exec
|
22
|
+
rake docs:generate ; else echo "Skipping doc generation" ; exit 0 ; fi '
|
23
|
+
- run:
|
24
|
+
name: Push documentation to Unwritten
|
25
|
+
command: if [[ $(bundle exec rake -T docs:push) ]]; then bundle exec rake
|
26
|
+
docs:push; fi
|
6
27
|
release:
|
7
28
|
docker:
|
8
|
-
- image: circleci/ruby:2.7.
|
29
|
+
- image: circleci/ruby:2.7.2
|
30
|
+
auth:
|
31
|
+
username: "$DOCKERHUB_USERNAME"
|
32
|
+
password: "$DOCKERHUB_PASSWORD"
|
9
33
|
steps:
|
10
34
|
- checkout
|
11
35
|
- run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
|
@@ -17,14 +41,22 @@ jobs:
|
|
17
41
|
- run:
|
18
42
|
name: Build/release gem to artifactory
|
19
43
|
command: bundle exec rake push_artifactory
|
20
|
-
ruby-2.7.
|
44
|
+
ruby-2.7.2-rails-6.0:
|
21
45
|
docker:
|
22
|
-
- image: circleci/ruby:2.7.
|
46
|
+
- image: circleci/ruby:2.7.2
|
47
|
+
auth:
|
48
|
+
username: "$DOCKERHUB_USERNAME"
|
49
|
+
password: "$DOCKERHUB_PASSWORD"
|
23
50
|
environment:
|
24
51
|
BUNDLE_GEMFILE: Gemfile.rails-6.0
|
25
52
|
working_directory: "~/stitches"
|
26
53
|
steps:
|
27
54
|
- checkout
|
55
|
+
- run:
|
56
|
+
name: Check for Gemfile.lock presence
|
57
|
+
command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
|
58
|
+
https://github.com/stitchfix/eng-wiki/blob/master/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
|
59
|
+
1>&2 ; exit 1 ; else exit 0 ; fi '
|
28
60
|
- run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
|
29
61
|
- run: bundle install --full-index
|
30
62
|
- run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
|
@@ -42,11 +74,19 @@ jobs:
|
|
42
74
|
ruby-2.6.6-rails-6.0:
|
43
75
|
docker:
|
44
76
|
- image: circleci/ruby:2.6.6
|
77
|
+
auth:
|
78
|
+
username: "$DOCKERHUB_USERNAME"
|
79
|
+
password: "$DOCKERHUB_PASSWORD"
|
45
80
|
environment:
|
46
81
|
BUNDLE_GEMFILE: Gemfile.rails-6.0
|
47
82
|
working_directory: "~/stitches"
|
48
83
|
steps:
|
49
84
|
- checkout
|
85
|
+
- run:
|
86
|
+
name: Check for Gemfile.lock presence
|
87
|
+
command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
|
88
|
+
https://github.com/stitchfix/eng-wiki/blob/master/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
|
89
|
+
1>&2 ; exit 1 ; else exit 0 ; fi '
|
50
90
|
- run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
|
51
91
|
- run: bundle install --full-index
|
52
92
|
- run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
|
@@ -61,14 +101,22 @@ jobs:
|
|
61
101
|
when: on_fail
|
62
102
|
- store_test_results:
|
63
103
|
path: "/tmp/test-results"
|
64
|
-
ruby-2.7.
|
104
|
+
ruby-2.7.2-rails-5.2:
|
65
105
|
docker:
|
66
|
-
- image: circleci/ruby:2.7.
|
106
|
+
- image: circleci/ruby:2.7.2
|
107
|
+
auth:
|
108
|
+
username: "$DOCKERHUB_USERNAME"
|
109
|
+
password: "$DOCKERHUB_PASSWORD"
|
67
110
|
environment:
|
68
111
|
BUNDLE_GEMFILE: Gemfile.rails-5.2
|
69
112
|
working_directory: "~/stitches"
|
70
113
|
steps:
|
71
114
|
- checkout
|
115
|
+
- run:
|
116
|
+
name: Check for Gemfile.lock presence
|
117
|
+
command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
|
118
|
+
https://github.com/stitchfix/eng-wiki/blob/master/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
|
119
|
+
1>&2 ; exit 1 ; else exit 0 ; fi '
|
72
120
|
- run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
|
73
121
|
- run: bundle install --full-index
|
74
122
|
- run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
|
@@ -86,11 +134,19 @@ jobs:
|
|
86
134
|
ruby-2.6.6-rails-5.2:
|
87
135
|
docker:
|
88
136
|
- image: circleci/ruby:2.6.6
|
137
|
+
auth:
|
138
|
+
username: "$DOCKERHUB_USERNAME"
|
139
|
+
password: "$DOCKERHUB_PASSWORD"
|
89
140
|
environment:
|
90
141
|
BUNDLE_GEMFILE: Gemfile.rails-5.2
|
91
142
|
working_directory: "~/stitches"
|
92
143
|
steps:
|
93
144
|
- checkout
|
145
|
+
- run:
|
146
|
+
name: Check for Gemfile.lock presence
|
147
|
+
command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
|
148
|
+
https://github.com/stitchfix/eng-wiki/blob/master/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
|
149
|
+
1>&2 ; exit 1 ; else exit 0 ; fi '
|
94
150
|
- run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
|
95
151
|
- run: bundle install --full-index
|
96
152
|
- run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
|
@@ -112,16 +168,25 @@ workflows:
|
|
112
168
|
- release:
|
113
169
|
context: org-global
|
114
170
|
requires:
|
115
|
-
- ruby-2.7.
|
171
|
+
- ruby-2.7.2-rails-6.0
|
116
172
|
- ruby-2.6.6-rails-6.0
|
117
|
-
- ruby-2.7.
|
173
|
+
- ruby-2.7.2-rails-5.2
|
118
174
|
- ruby-2.6.6-rails-5.2
|
119
175
|
filters:
|
120
176
|
tags:
|
121
|
-
only: /^[0-9]+\.[0-9]+\.[0-9]+(\.?(RC|rc)[-\.]?\
|
177
|
+
only: /^[0-9]+\.[0-9]+\.[0-9]+(\.?(RC|rc)[-\.]?\w*)?$/
|
178
|
+
branches:
|
179
|
+
ignore: /.*/
|
180
|
+
- generate-and-push-docs:
|
181
|
+
context: org-global
|
182
|
+
requires:
|
183
|
+
- release
|
184
|
+
filters:
|
185
|
+
tags:
|
186
|
+
only: /^[0-9]+\.[0-9]+\.[0-9]+(\.?(RC|rc)[-\.]?\w*)?$/
|
122
187
|
branches:
|
123
188
|
ignore: /.*/
|
124
|
-
- ruby-2.7.
|
189
|
+
- ruby-2.7.2-rails-6.0:
|
125
190
|
context: org-global
|
126
191
|
filters:
|
127
192
|
tags:
|
@@ -131,7 +196,7 @@ workflows:
|
|
131
196
|
filters:
|
132
197
|
tags:
|
133
198
|
only: *1
|
134
|
-
- ruby-2.7.
|
199
|
+
- ruby-2.7.2-rails-5.2:
|
135
200
|
context: org-global
|
136
201
|
filters:
|
137
202
|
tags:
|
@@ -150,11 +215,11 @@ workflows:
|
|
150
215
|
only:
|
151
216
|
- master
|
152
217
|
jobs:
|
153
|
-
- ruby-2.7.
|
218
|
+
- ruby-2.7.2-rails-6.0:
|
154
219
|
context: org-global
|
155
220
|
- ruby-2.6.6-rails-6.0:
|
156
221
|
context: org-global
|
157
|
-
- ruby-2.7.
|
222
|
+
- ruby-2.7.2-rails-5.2:
|
158
223
|
context: org-global
|
159
224
|
- ruby-2.6.6-rails-5.2:
|
160
225
|
context: org-global
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.7.
|
1
|
+
2.7.2
|
@@ -1,19 +1,26 @@
|
|
1
1
|
require_relative 'allowlist_middleware'
|
2
2
|
module Stitches
|
3
|
-
# A middleware that requires all API calls to be for versioned JSON
|
4
|
-
#
|
3
|
+
# A middleware that requires all API calls to be for versioned JSON or Protobuf.
|
4
|
+
#
|
5
|
+
# This means that the Accept header (available to Rack apps as HTTP_ACCEPT) should be like so:
|
5
6
|
#
|
6
7
|
# application/json; version=1
|
7
8
|
#
|
8
9
|
# This just checks that you've specified some numeric version. ApiVersionConstraint should be used
|
9
10
|
# to "lock down" the versions you accept.
|
11
|
+
#
|
12
|
+
# Or in the case of a protobuf encoded payload the header should be like so:
|
13
|
+
#
|
14
|
+
# application/protobuf
|
15
|
+
#
|
16
|
+
# There isn't an accepted standard for protobuf encoded payloads but this form is common.
|
10
17
|
class ValidMimeType < Stitches::AllowlistMiddleware
|
11
18
|
|
12
19
|
protected
|
13
20
|
|
14
21
|
def do_call(env)
|
15
22
|
accept = String(env["HTTP_ACCEPT"])
|
16
|
-
if accept =~ %r{application/json} && accept =~ %r{version=\d+}
|
23
|
+
if (accept =~ %r{application/json} && accept =~ %r{version=\d+}) || accept =~ %r{application/protobuf}
|
17
24
|
@app.call(env)
|
18
25
|
else
|
19
26
|
not_acceptable_response(accept)
|
@@ -24,7 +31,7 @@ module Stitches
|
|
24
31
|
|
25
32
|
def not_acceptable_response(accept_header)
|
26
33
|
status = 406
|
27
|
-
body = "Not Acceptable - '#{accept_header}' didn't have the right mime type or version number. We only accept application/json with a version"
|
34
|
+
body = "Not Acceptable - '#{accept_header}' didn't have the right mime type or version number. We only accept application/json with a version or application/protobuf"
|
28
35
|
header = { "WWW-Authenticate" => accept_header }
|
29
36
|
Rack::Response.new(body, status, header).finish
|
30
37
|
end
|
data/lib/stitches/version.rb
CHANGED
@@ -132,6 +132,22 @@ describe Stitches::ValidMimeType do
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
context "protbuf mime type" do
|
136
|
+
let(:env) {
|
137
|
+
{
|
138
|
+
"PATH_INFO" => "/api/ping",
|
139
|
+
"HTTP_ACCEPT" => "application/protobuf",
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
before do
|
144
|
+
@response = middleware.call(env)
|
145
|
+
end
|
146
|
+
it "calls through to the rest of the chain" do
|
147
|
+
expect(app).to have_received(:call).with(env)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
135
151
|
context "unacceptable responses" do
|
136
152
|
before do
|
137
153
|
@response = middleware.call(env)
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stitches
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stitch Fix Engineering
|
8
8
|
- Andrew Peterson
|
9
9
|
- Dave Copeland
|
10
10
|
- Jonathan Dean
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2020-
|
14
|
+
date: 2020-11-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -184,7 +184,7 @@ homepage: https://github.com/stitchfix/stitches
|
|
184
184
|
licenses:
|
185
185
|
- MIT
|
186
186
|
metadata: {}
|
187
|
-
post_install_message:
|
187
|
+
post_install_message:
|
188
188
|
rdoc_options: []
|
189
189
|
require_paths:
|
190
190
|
- lib
|
@@ -199,8 +199,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
199
|
- !ruby/object:Gem::Version
|
200
200
|
version: '0'
|
201
201
|
requirements: []
|
202
|
-
rubygems_version: 3.1.
|
203
|
-
signing_key:
|
202
|
+
rubygems_version: 3.1.4
|
203
|
+
signing_key:
|
204
204
|
specification_version: 4
|
205
205
|
summary: You'll be in stitches at how easy it is to create a service at Stitch Fix
|
206
206
|
test_files:
|