test_server 0.2.4 → 0.3.1

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.
Files changed (106) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +3 -0
  3. data/Gemfile +54 -29
  4. data/README.rdoc +28 -0
  5. data/Rakefile +3 -3
  6. data/app/assets/images/.keep +0 -0
  7. data/app/assets/javascripts/application.js +14 -0
  8. data/app/assets/javascripts/errors.js +2 -0
  9. data/app/assets/stylesheets/application.scss +83 -0
  10. data/app/assets/stylesheets/errors.css +4 -0
  11. data/app/controllers/concerns/.keep +0 -0
  12. data/app/controllers/test_server/application_controller.rb +34 -0
  13. data/app/controllers/test_server/dashboard_controller.rb +9 -0
  14. data/app/controllers/test_server/errors_controller.rb +22 -0
  15. data/app/controllers/test_server/generator_controller.rb +40 -0
  16. data/app/controllers/test_server/static_controller.rb +16 -0
  17. data/app/controllers/test_server/streaming_controller.rb +56 -0
  18. data/app/controllers/test_server/string_controller.rb +39 -0
  19. data/app/helpers/application_helper.rb +2 -0
  20. data/app/helpers/errors_helper.rb +2 -0
  21. data/app/mailers/.keep +0 -0
  22. data/app/models/.keep +0 -0
  23. data/app/models/concerns/.keep +0 -0
  24. data/app/views/layouts/application.html.haml +59 -0
  25. data/app/views/shared/_overview.html.haml +16 -0
  26. data/app/views/test_server/dashboard/show.html.haml +7 -0
  27. data/app/views/test_server/errors/not_found.html.haml +2 -0
  28. data/app/views/test_server/errors/show.html.haml +6 -0
  29. data/app/views/test_server/generator/_overview.html.haml +1 -0
  30. data/app/views/test_server/generator/index.html.haml +1 -0
  31. data/app/views/{xhr/show.haml → test_server/generator/xhr.html.haml} +15 -12
  32. data/app/views/test_server/static/_overview.html.haml +1 -0
  33. data/app/views/test_server/static/index.html.haml +1 -0
  34. data/app/views/test_server/streaming/_overview.html.haml +1 -0
  35. data/app/views/test_server/streaming/index.html.haml +1 -0
  36. data/app/views/test_server/string/_overview.html.haml +1 -0
  37. data/app/views/test_server/string/index.html.haml +1 -0
  38. data/config.ru +3 -50
  39. data/config/application.rb +44 -0
  40. data/config/boot.rb +4 -0
  41. data/config/database.yml +25 -0
  42. data/config/environment.rb +5 -0
  43. data/config/environments/development.rb +37 -0
  44. data/config/environments/production.rb +87 -0
  45. data/config/environments/profile.rb +85 -0
  46. data/config/environments/test.rb +39 -0
  47. data/config/initializers/backtrace_silencers.rb +7 -0
  48. data/config/initializers/breadbrumb_builder.rb +24 -0
  49. data/config/initializers/change_values.rb +5 -0
  50. data/config/initializers/cookies_serializer.rb +3 -0
  51. data/config/initializers/filter_parameter_logging.rb +4 -0
  52. data/config/initializers/inflections.rb +16 -0
  53. data/config/initializers/mime_types.rb +4 -0
  54. data/config/initializers/session_store.rb +3 -0
  55. data/config/initializers/to_bool.rb +23 -0
  56. data/config/initializers/wrap_parameters.rb +14 -0
  57. data/config/locales/en.yml +23 -0
  58. data/config/routes.rb +78 -0
  59. data/config/secrets.yml +22 -0
  60. data/lib/assets/.keep +0 -0
  61. data/lib/tasks/.keep +0 -0
  62. data/lib/test_server.rb +13 -15
  63. data/lib/test_server/error_handler.rb +15 -11
  64. data/lib/test_server/error_messages.rb +16 -6
  65. data/lib/test_server/exceptions.rb +6 -0
  66. data/lib/test_server/locales/en.yml +55 -2
  67. data/lib/test_server/permitted_params.rb +107 -0
  68. data/lib/test_server/version.rb +1 -1
  69. data/lib/test_server/web_helper.rb +7 -31
  70. data/log/.keep +0 -0
  71. data/log/development.log +0 -0
  72. data/log/test.log +1 -0
  73. data/public/404.html +67 -0
  74. data/public/422.html +67 -0
  75. data/public/500.html +66 -0
  76. data/public/favicon.ico +0 -0
  77. data/public/robots.txt +5 -0
  78. data/public/static/plain.html +11 -0
  79. data/script/bundle +3 -0
  80. data/script/rails +8 -0
  81. data/script/rake +8 -0
  82. data/script/spring +18 -0
  83. data/spec/controllers/errors_controller_spec.rb +12 -0
  84. data/spec/error_handler_spec.rb +42 -9
  85. data/spec/features/dashboard_spec.rb +35 -0
  86. data/spec/features/fetch_data_via_javascript_spec.rb +14 -14
  87. data/spec/features/fetch_test_data_plain_spec.rb +11 -29
  88. data/spec/features/fetch_test_data_via_streaming_spec.rb +6 -6
  89. data/spec/features/helper_spec.rb +23 -31
  90. data/spec/helpers/errors_helper_spec.rb +15 -0
  91. data/spec/permitted_params_spec.rb +64 -0
  92. data/spec/spec_helper.rb +44 -3
  93. data/spec/support/capybara.rb +4 -0
  94. data/spec/support/rails.rb +33 -0
  95. data/spec/views/errors/not_found.html.haml_spec.rb +5 -0
  96. data/test_server.gemspec +18 -17
  97. data/vendor/assets/components/open-sans/scss/_base.scss +5 -5
  98. data/vendor/assets/javascripts/.keep +0 -0
  99. data/vendor/assets/stylesheets/.keep +0 -0
  100. metadata +133 -116
  101. data/app/controllers/application_controller.rb +0 -76
  102. data/app/controllers/assets_controller.rb +0 -73
  103. data/app/controllers/javascript_controller.rb +0 -36
  104. data/app/controllers/streaming_controller.rb +0 -52
  105. data/app/controllers/string_controller.rb +0 -51
  106. data/app/views/layouts/application.haml +0 -19
@@ -1,76 +0,0 @@
1
- # encoding: utf-8
2
- module TestServer
3
- module App
4
- class ApplicationController < Sinatra::Base
5
- set :root, ::File.expand_path('../../', __FILE__)
6
- set :haml, :format => :html5
7
-
8
- enable :protect_from_csrf
9
- enable :protection
10
- enable :session
11
- enable :report_csrf_failure
12
-
13
- register Padrino::Helpers
14
- register Padrino::Routing
15
-
16
- use Rack::Deflater
17
- use Rack::Locale
18
- use Rack::NestedParams
19
- use Rack::PostBodyContentTypeParser
20
-
21
- helpers Sinatra::Param
22
-
23
- error do
24
- handler = ErrorHandler.find(StandardError)
25
-
26
- @error_summary = handler.summary(:html)
27
- @error_details = handler.details(:html)
28
-
29
- halt 500, haml(:error, layout: :application)
30
- end
31
-
32
- set :raise_sinatra_param_exceptions, true
33
-
34
- error Sinatra::Param::InvalidParameterError do
35
- handler = ErrorHandler.find(Sinatra::Param::InvalidParameterError)
36
- handler.use(JSON.dump(parameter: env['sinatra.error'].param))
37
-
38
- @error_summary = handler.summary(:html)
39
- @error_details = handler.details(:html)
40
-
41
- halt 401, haml(:error, layout: :application)
42
- end
43
-
44
- configure :profile do
45
- require 'ruby-prof'
46
- use Rack::RubyProf, files: '/tmp/profiles'
47
-
48
- use Rack::CommonLogger, TestServer::AccessLogger.new(TestServer.config.access_log)
49
- set :raise_errors, false
50
- end
51
-
52
- configure :production do
53
- use Rack::CommonLogger, TestServer::AccessLogger.new(TestServer.config.access_log)
54
- set :raise_errors, false
55
- end
56
-
57
- configure :development do
58
- set :raise_errors, true
59
-
60
- before do
61
- TestServer.ui_logger.debug "Parameters: " + params.to_s
62
- end
63
- end
64
-
65
- configure :test do
66
- use Rack::CommonLogger, TestServer::NullAccessLogger.new
67
- set :raise_errors, false
68
- end
69
-
70
- helpers do
71
- include Sprockets::Helpers
72
- include TestServer::WebHelper
73
- end
74
- end
75
- end
76
- end
@@ -1,73 +0,0 @@
1
- require 'compass'
2
- require 'sass'
3
- require 'sinatra'
4
- require 'sprockets'
5
- require 'sprockets-sass'
6
- require 'compass'
7
- require 'uglifier'
8
-
9
- # encoding: utf-8
10
- module TestServer
11
- module App
12
- class AssetsController < Sinatra::Base
13
- set :root, ::File.expand_path('../../', __FILE__)
14
- set :assets, Sprockets::Environment.new(root)
15
- set :precompile, [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
16
- set :assets_prefix, '/assets'
17
- set :digest_assets, false
18
- set(:assets_path) { ::File.join public_folder, assets_prefix }
19
-
20
- enable :protection
21
- enable :session
22
-
23
- configure :profile do
24
- require 'ruby-prof'
25
- use Rack::RubyProf, files: '/tmp/profiles'
26
-
27
- use Rack::CommonLogger, TestServer::AccessLogger.new(TestServer.config.access_log)
28
- set :raise_errors, false
29
- end
30
-
31
- configure :production do
32
- use Rack::CommonLogger, TestServer::AccessLogger.new(TestServer.config.access_log)
33
- set :raise_errors, false
34
- set :digest_assets, true
35
-
36
- assets.js_compressor = :uglify
37
- assets.css_compressor = :scss
38
- end
39
-
40
- configure :development do
41
- set :raise_errors, true
42
- end
43
-
44
- configure :test do
45
- use Rack::CommonLogger, TestServer::NullAccessLogger.new
46
- set :raise_errors, true
47
- end
48
-
49
- configure do
50
-
51
- # Setup Sprockets
52
- %w{javascripts stylesheets images}.each do |type|
53
- assets.append_path "assets/#{type}"
54
- end
55
- assets.append_path ::File.expand_path("../../../vendor/assets/components", __FILE__)
56
- assets.append_path ::File.expand_path("../../../vendor/assets/components/*/scss", __FILE__)
57
-
58
- assets.cache = Sprockets::Cache::FileStore.new(TestServer.config.sass_cache)
59
-
60
- # Configure Sprockets::Helpers (if necessary)
61
- Sprockets::Helpers.configure do |config|
62
- config.environment = assets
63
- config.prefix = assets_prefix
64
- config.digest = digest_assets
65
- config.public_path = public_folder
66
- end
67
-
68
- Sprockets::Sass.add_sass_functions = false
69
- end
70
-
71
- end
72
- end
73
- end
@@ -1,36 +0,0 @@
1
- # encoding: utf-8
2
- module TestServer
3
- module App
4
- class JavascriptController < ApplicationController
5
- #use Rack::Cors do
6
- # allow do
7
- # origins '*'
8
- # resource '*', :headers => :any, :methods => [:get, :post]
9
- # end
10
- #end
11
-
12
- before do
13
- param :no_cache, Boolean, default: false
14
- param :must_revalidate, Boolean, default: false
15
- param :max_age, Integer
16
- param :base64, Boolean, default: false
17
-
18
- configure_caching(params)
19
- end
20
-
21
- get :url, map: '/xhr/url' do
22
- param :count, Integer, default: 10
23
- param :timeout, Integer, default: 1_000
24
- param :url, String
25
- param :repeat, String, default: 'false'
26
-
27
- @count = params[:count]
28
- @url = params[:url]
29
- @timeout = params[:timeout]
30
- @repeat = %w{ on yes true t }.include?(params[:repeat])
31
-
32
- render 'xhr/show', layout: :application
33
- end
34
- end
35
- end
36
- end
@@ -1,52 +0,0 @@
1
- # encoding: utf-8
2
- module TestServer
3
- module App
4
- class StreamingController < ApplicationController
5
- helpers Sinatra::Streaming
6
-
7
- before do
8
- param :base64, Boolean, default: false
9
- end
10
-
11
- helpers do
12
- def stream_data(&block)
13
- content_type :stream
14
- cache_control :no_cache, :must_revalidate
15
-
16
- stream(&block)
17
- end
18
- end
19
-
20
- configure do
21
- mime_type :stream, 'text/plain'
22
- end
23
-
24
- get :index, map: '/' do
25
- redirect to('/default/')
26
- end
27
-
28
- get :string, map: '/default' do
29
- param :count, Integer, default: 10
30
-
31
- count = params[:count]
32
-
33
- stream_data do |out|
34
- out << encode { "Data #{count} times repeated" }
35
-
36
- count.times do |n|
37
- out << encode { "#{n + 1}: data" }
38
- sleep 1
39
- end
40
- end
41
- end
42
-
43
- get :eicar, map: '/eicar' do
44
- stream_data do |out|
45
- generate_eicar.each do |c|
46
- out << encode { c }
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,51 +0,0 @@
1
- # encoding: utf-8
2
- module TestServer
3
- module App
4
- class StringController < ApplicationController
5
-
6
- before do
7
- param :no_cache, Boolean, default: false
8
- param :must_revalidate, Boolean, default: false
9
- param :max_age, Integer
10
- param :base64, Boolean, default: false
11
-
12
- configure_caching(params)
13
- end
14
-
15
- get :index, map: '/' do
16
- redirect to('/default/')
17
- end
18
-
19
- get :string, map: '/default' do
20
- param :count, Integer, default: 1
21
-
22
- encode do
23
- generate_string(params[:count])
24
- end
25
- end
26
-
27
- get :eicar, map: '/eicar' do
28
- encode do
29
- generate_eicar.join
30
- end
31
- end
32
-
33
- get :sleep, map: '/sleep' do
34
- param :count, Integer, default: 120
35
- sleep params[:count]
36
-
37
- encode do
38
- generate_string(1)
39
- end
40
- end
41
-
42
- get :random, map: '/random' do
43
- param :count, Integer, default: 10
44
-
45
- encode do
46
- generate_random_string(params[:count])
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,19 +0,0 @@
1
- !!!
2
- %html
3
- %head
4
- %meta{ charset: 'utf-8'}
5
- %link{ rel: 'stylesheet', href: stylesheet_path('application.css') }
6
- %title= @title || t('views.application.title')
7
- %body
8
- .ts-page-header
9
- %nav.ts-top-navigation
10
- %ul.nav.navbar-nav
11
- %li
12
- %a{href: '/'}
13
- = t('views.root.link')
14
- %li.active
15
- %a{href: '/v1/test/'}
16
- = t('views.test.link')
17
- .ts-container
18
- = yield
19
- %script{ type: 'text/javascript', src: javascript_path('application.js') }