Skip to content

Commit

Permalink
Merge pull request #614 from hanami/subresurce-integrity
Browse files Browse the repository at this point in the history
Subresource Integrity
  • Loading branch information
jodosha committed Jul 16, 2016
2 parents f0e376d + 019d467 commit 3de59a1
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 10 deletions.
5 changes: 5 additions & 0 deletions lib/hanami/generators/app/application.rb.tt
Expand Up @@ -327,6 +327,11 @@ module <%= config[:classified_app_name] %>
# scheme 'https'
# host 'cdn.example.org'
# port 443

# Subresource Integrity
#
# See: http://hanamirb.org/guides/assets/subresource-integrity
subresource_integrity :sha256
end
end
end
Expand Down
Expand Up @@ -326,6 +326,11 @@ module <%= config[:classified_app_name] %>
# scheme 'https'
# host 'cdn.example.org'
# port 443

# Subresource Integrity
#
# See: http://hanamirb.org/guides/assets/subresource-integrity
subresource_integrity :sha256
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/cdn/cdn/apps/web/application.rb
Expand Up @@ -259,6 +259,11 @@ class Application < Hanami::Application
scheme 'https'
host 'cdn.example.org'
port 443

# Subresource Integrity
#
# See: http://hanamirb.org/guides/assets/subresource-integrity
subresource_integrity :sha256
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/cdn/cdn_app/config/application.rb
Expand Up @@ -256,6 +256,11 @@ class Application < Hanami::Application
scheme 'https'
host 'cdn.example.org'
port 443

# Subresource Integrity
#
# See: http://hanamirb.org/guides/assets/subresource-integrity
subresource_integrity :sha256
end
end
end
Expand Down
Expand Up @@ -326,6 +326,11 @@ class Application < Hanami::Application
# scheme 'https'
# host 'cdn.example.org'
# port 443

# Subresource Integrity
#
# See: http://hanamirb.org/guides/assets/subresource-integrity
subresource_integrity :sha256
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/commands/generate/app/application.rb
Expand Up @@ -327,6 +327,11 @@ class Application < Hanami::Application
# scheme 'https'
# host 'cdn.example.org'
# port 443

# Subresource Integrity
#
# See: http://hanamirb.org/guides/assets/subresource-integrity
subresource_integrity :sha256
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/rake/rake_tasks/apps/web/application.rb
Expand Up @@ -282,6 +282,11 @@ class Application < Hanami::Application
# scheme 'https'
# host 'cdn.example.org'
# port 443

# Subresource Integrity
#
# See: http://hanamirb.org/guides/assets/subresource-integrity
subresource_integrity :sha256
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/rake/rake_tasks_app/config/application.rb
Expand Up @@ -279,6 +279,11 @@ class Application < Hanami::Application
# scheme 'https'
# host 'cdn.example.org'
# port 443

# Subresource Integrity
#
# See: http://hanamirb.org/guides/assets/subresource-integrity
subresource_integrity :sha256
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions test/fixtures/static_assets/apps/web/application.rb
Expand Up @@ -242,8 +242,9 @@ class Application < Hanami::Application
# port 443

assets do
compile false
digest true
compile false
digest true
subresource_integrity :sha256
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions test/fixtures/static_assets_app/config/application.rb
Expand Up @@ -238,8 +238,9 @@ class Application < Hanami::Application
# port 443

assets do
compile false
digest true
compile false
digest true
subresource_integrity :sha256
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/integration/assets_digest_mode/test_application.rb
Expand Up @@ -41,7 +41,7 @@
get '/'

body = response.body
body.must_include %(<link href="/assets/application-5ebdabab46f08c2cc8d56425bb34bc38.css" type="text/css" rel="stylesheet">)
body.must_include %(<link href="/assets/home-c229183232e6cfbf965a21ec0b06ee06.css" type="text/css" rel="stylesheet">)
body.must_include %(<link href="/assets/application-5ebdabab46f08c2cc8d56425bb34bc38.css" type="text/css" rel="stylesheet" integrity="sha256-VEro4QEXHHqDBtV8a9UG25qlAgrkuMWBSahU8LyTsoM=" crossorigin="anonymous">)
body.must_include %(<link href="/assets/home-c229183232e6cfbf965a21ec0b06ee06.css" type="text/css" rel="stylesheet" integrity="sha256-3Ji7O2PJXQknS787XmhURSk7V55X6RH4gKESO6KkQXg=" crossorigin="anonymous">)
end
end
4 changes: 2 additions & 2 deletions test/integration/assets_digest_mode/test_container.rb
Expand Up @@ -41,7 +41,7 @@
get '/'

body = response.body
body.must_include %(<link href="/assets/application-34a87596e5ba23b89a36e910c15bfb43.css" type="text/css" rel="stylesheet">)
body.must_include %(<link href="/assets/home-c229183232e6cfbf965a21ec0b06ee06.css" type="text/css" rel="stylesheet">)
body.must_include %(<link href="/assets/application-34a87596e5ba23b89a36e910c15bfb43.css" type="text/css" rel="stylesheet" integrity="sha256-cecPoVv30ok4eSZPigy/vuCGANzjK7z3+lbg2Ml3c6Q=" crossorigin="anonymous">)
body.must_include %(<link href="/assets/home-c229183232e6cfbf965a21ec0b06ee06.css" type="text/css" rel="stylesheet" integrity="sha256-3Ji7O2PJXQknS787XmhURSk7V55X6RH4gKESO6KkQXg=" crossorigin="anonymous">)
end
end
2 changes: 1 addition & 1 deletion test/integration/cdn/test_application.rb
Expand Up @@ -29,6 +29,6 @@
body = get("/").body

body.must_include %(<link href="https://cdn.example.org/assets/favicon-4b49a383ea9cf9a46820b3a2374de6fe.ico" rel="shortcut icon" type="image/x-icon">)
body.must_include %(<link href="https://cdn.example.org/assets/charge-b45434daf18d5b0deb8aeab4220f5b86.css" type="text/css" rel="stylesheet">)
body.must_include %(<link href="https://cdn.example.org/assets/charge-b45434daf18d5b0deb8aeab4220f5b86.css" type="text/css" rel="stylesheet" integrity="sha256-I8HgEXbjXzt1ussZzYxC78SjglSglPiQVRsj4PyXQUo=" crossorigin="anonymous">)
end
end
2 changes: 1 addition & 1 deletion test/integration/cdn/test_container.rb
Expand Up @@ -34,6 +34,6 @@
body = get("/").body

body.must_include %(<link href="https://cdn.example.org/assets/favicon-4b49a383ea9cf9a46820b3a2374de6fe.ico" rel="shortcut icon" type="image/x-icon">)
body.must_include %(<script src="https://cdn.example.org/assets/analytics-9fd60e0c3af3bb376e3c17f65ac751cd.js" type="text/javascript"></script>)
body.must_include %(<script src="https://cdn.example.org/assets/analytics-9fd60e0c3af3bb376e3c17f65ac751cd.js" type="text/javascript" integrity="sha256-G49CSbDPAbNLHGmRifXBjsdtJLaAE0SKYhjcNYXTqGc=" crossorigin="anonymous"></script>)
end
end

0 comments on commit 3de59a1

Please sign in to comment.