appmap 0.31.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.dockerignore +5 -0
- data/.gitignore +17 -0
- data/.rubocop.yml +27 -0
- data/.ruby-version +1 -0
- data/.travis.yml +44 -0
- data/CHANGELOG.md +199 -0
- data/Dockerfile.appmap +5 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +300 -0
- data/Rakefile +132 -0
- data/appmap.gemspec +44 -0
- data/appmap.yml +8 -0
- data/examples/install.rb +76 -0
- data/examples/mock_webapp/Gemfile +1 -0
- data/examples/mock_webapp/appmap.yml +2 -0
- data/examples/mock_webapp/exe/mock_webapp_request +12 -0
- data/examples/mock_webapp/lib/mock_webapp/controller.rb +23 -0
- data/examples/mock_webapp/lib/mock_webapp/request.rb +12 -0
- data/examples/mock_webapp/lib/mock_webapp/user.rb +18 -0
- data/exe/appmap +154 -0
- data/lib/appmap.rb +87 -0
- data/lib/appmap/algorithm/prune_class_map.rb +67 -0
- data/lib/appmap/algorithm/stats.rb +91 -0
- data/lib/appmap/class_map.rb +135 -0
- data/lib/appmap/command/record.rb +38 -0
- data/lib/appmap/command/stats.rb +14 -0
- data/lib/appmap/config.rb +91 -0
- data/lib/appmap/cucumber.rb +89 -0
- data/lib/appmap/event.rb +168 -0
- data/lib/appmap/hook.rb +130 -0
- data/lib/appmap/metadata.rb +62 -0
- data/lib/appmap/middleware/remote_recording.rb +114 -0
- data/lib/appmap/minitest.rb +141 -0
- data/lib/appmap/rails/action_handler.rb +91 -0
- data/lib/appmap/rails/sql_handler.rb +145 -0
- data/lib/appmap/railtie.rb +45 -0
- data/lib/appmap/record.rb +27 -0
- data/lib/appmap/rspec.rb +301 -0
- data/lib/appmap/trace.rb +96 -0
- data/lib/appmap/util.rb +40 -0
- data/lib/appmap/version.rb +9 -0
- data/lore/pages/2019-05-21-install-and-record/index.pug +51 -0
- data/lore/pages/2019-05-21-install-and-record/install_example_appmap.png +0 -0
- data/lore/pages/2019-05-21-install-and-record/metadata.yml +5 -0
- data/lore/pages/layout.pug +66 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.css +1912 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.min.css +7 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.min.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.css +331 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.min.css +8 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.min.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.css +9030 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.min.css +7 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.min.css.map +1 -0
- data/lore/public/stylesheets/style.css +8 -0
- data/package-lock.json +1064 -0
- data/package.json +24 -0
- data/spec/abstract_controller4_base_spec.rb +67 -0
- data/spec/abstract_controller_base_spec.rb +72 -0
- data/spec/config_spec.rb +25 -0
- data/spec/fixtures/hook/attr_accessor.rb +5 -0
- data/spec/fixtures/hook/compare.rb +7 -0
- data/spec/fixtures/hook/constructor.rb +7 -0
- data/spec/fixtures/hook/exception_method.rb +11 -0
- data/spec/fixtures/hook/instance_method.rb +23 -0
- data/spec/fixtures/hook/openssl_sign.rb +87 -0
- data/spec/fixtures/hook/singleton_method.rb +54 -0
- data/spec/fixtures/rack_users_app/.dockerignore +2 -0
- data/spec/fixtures/rack_users_app/.gitignore +2 -0
- data/spec/fixtures/rack_users_app/Dockerfile +32 -0
- data/spec/fixtures/rack_users_app/Gemfile +10 -0
- data/spec/fixtures/rack_users_app/appmap.yml +3 -0
- data/spec/fixtures/rack_users_app/config.ru +2 -0
- data/spec/fixtures/rack_users_app/docker-compose.yml +9 -0
- data/spec/fixtures/rack_users_app/lib/app.rb +36 -0
- data/spec/fixtures/rails4_users_app/.gitignore +13 -0
- data/spec/fixtures/rails4_users_app/.rbenv-gemsets +2 -0
- data/spec/fixtures/rails4_users_app/.ruby-version +1 -0
- data/spec/fixtures/rails4_users_app/Dockerfile +30 -0
- data/spec/fixtures/rails4_users_app/Dockerfile.pg +3 -0
- data/spec/fixtures/rails4_users_app/Gemfile +77 -0
- data/spec/fixtures/rails4_users_app/README.rdoc +28 -0
- data/spec/fixtures/rails4_users_app/Rakefile +6 -0
- data/spec/fixtures/rails4_users_app/app/assets/images/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/assets/javascripts/application.js +16 -0
- data/spec/fixtures/rails4_users_app/app/assets/stylesheets/application.css +15 -0
- data/spec/fixtures/rails4_users_app/app/controllers/api/users_controller.rb +27 -0
- data/spec/fixtures/rails4_users_app/app/controllers/application_controller.rb +5 -0
- data/spec/fixtures/rails4_users_app/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/controllers/health_controller.rb +5 -0
- data/spec/fixtures/rails4_users_app/app/controllers/users_controller.rb +5 -0
- data/spec/fixtures/rails4_users_app/app/helpers/application_helper.rb +2 -0
- data/spec/fixtures/rails4_users_app/app/mailers/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/concerns/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/user.rb +18 -0
- data/spec/fixtures/rails4_users_app/app/views/layouts/application.html.haml +7 -0
- data/spec/fixtures/rails4_users_app/app/views/users/index.html.haml +7 -0
- data/spec/fixtures/rails4_users_app/appmap.yml +3 -0
- data/spec/fixtures/rails4_users_app/bin/rails +9 -0
- data/spec/fixtures/rails4_users_app/bin/setup +29 -0
- data/spec/fixtures/rails4_users_app/bin/spring +17 -0
- data/spec/fixtures/rails4_users_app/config.ru +4 -0
- data/spec/fixtures/rails4_users_app/config/application.rb +26 -0
- data/spec/fixtures/rails4_users_app/config/boot.rb +3 -0
- data/spec/fixtures/rails4_users_app/config/database.yml +18 -0
- data/spec/fixtures/rails4_users_app/config/environment.rb +5 -0
- data/spec/fixtures/rails4_users_app/config/environments/development.rb +41 -0
- data/spec/fixtures/rails4_users_app/config/environments/production.rb +79 -0
- data/spec/fixtures/rails4_users_app/config/environments/test.rb +42 -0
- data/spec/fixtures/rails4_users_app/config/initializers/assets.rb +11 -0
- data/spec/fixtures/rails4_users_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/fixtures/rails4_users_app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/fixtures/rails4_users_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/fixtures/rails4_users_app/config/initializers/inflections.rb +16 -0
- data/spec/fixtures/rails4_users_app/config/initializers/mime_types.rb +4 -0
- data/spec/fixtures/rails4_users_app/config/initializers/session_store.rb +3 -0
- data/spec/fixtures/rails4_users_app/config/initializers/to_time_preserves_timezone.rb +10 -0
- data/spec/fixtures/rails4_users_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/fixtures/rails4_users_app/config/locales/en.yml +23 -0
- data/spec/fixtures/rails4_users_app/config/routes.rb +12 -0
- data/spec/fixtures/rails4_users_app/config/secrets.yml +22 -0
- data/spec/fixtures/rails4_users_app/create_app +23 -0
- data/spec/fixtures/rails4_users_app/db/migrate/20191127112304_create_users.rb +10 -0
- data/spec/fixtures/rails4_users_app/db/schema.rb +26 -0
- data/spec/fixtures/rails4_users_app/db/seeds.rb +7 -0
- data/spec/fixtures/rails4_users_app/docker-compose.yml +26 -0
- data/spec/fixtures/rails4_users_app/lib/assets/.keep +0 -0
- data/spec/fixtures/rails4_users_app/lib/tasks/.keep +0 -0
- data/spec/fixtures/rails4_users_app/log/.keep +0 -0
- data/spec/fixtures/rails4_users_app/public/404.html +67 -0
- data/spec/fixtures/rails4_users_app/public/422.html +67 -0
- data/spec/fixtures/rails4_users_app/public/500.html +66 -0
- data/spec/fixtures/rails4_users_app/public/favicon.ico +0 -0
- data/spec/fixtures/rails4_users_app/public/robots.txt +5 -0
- data/spec/fixtures/rails4_users_app/spec/controllers/users_controller_api_spec.rb +49 -0
- data/spec/fixtures/rails4_users_app/spec/rails_helper.rb +95 -0
- data/spec/fixtures/rails4_users_app/spec/spec_helper.rb +96 -0
- data/spec/fixtures/rails4_users_app/test/fixtures/users.yml +9 -0
- data/spec/fixtures/rails_users_app/.dockerignore +1 -0
- data/spec/fixtures/rails_users_app/.gitignore +39 -0
- data/spec/fixtures/rails_users_app/.rspec +1 -0
- data/spec/fixtures/rails_users_app/.ruby-version +1 -0
- data/spec/fixtures/rails_users_app/Dockerfile +29 -0
- data/spec/fixtures/rails_users_app/Dockerfile.pg +3 -0
- data/spec/fixtures/rails_users_app/Gemfile +52 -0
- data/spec/fixtures/rails_users_app/Rakefile +6 -0
- data/spec/fixtures/rails_users_app/app/controllers/api/users_controller.rb +27 -0
- data/spec/fixtures/rails_users_app/app/controllers/application_controller.rb +2 -0
- data/spec/fixtures/rails_users_app/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/rails_users_app/app/controllers/health_controller.rb +5 -0
- data/spec/fixtures/rails_users_app/app/controllers/users_controller.rb +5 -0
- data/spec/fixtures/rails_users_app/app/models/activerecord/user.rb +18 -0
- data/spec/fixtures/rails_users_app/app/models/concerns/.keep +0 -0
- data/spec/fixtures/rails_users_app/app/models/sequel/user.rb +25 -0
- data/spec/fixtures/rails_users_app/app/views/layouts/application.html.haml +7 -0
- data/spec/fixtures/rails_users_app/app/views/users/index.html.haml +7 -0
- data/spec/fixtures/rails_users_app/appmap.yml +3 -0
- data/spec/fixtures/rails_users_app/bin/appmap +29 -0
- data/spec/fixtures/rails_users_app/bin/byebug +29 -0
- data/spec/fixtures/rails_users_app/bin/gli +29 -0
- data/spec/fixtures/rails_users_app/bin/htmldiff +29 -0
- data/spec/fixtures/rails_users_app/bin/ldiff +29 -0
- data/spec/fixtures/rails_users_app/bin/nokogiri +29 -0
- data/spec/fixtures/rails_users_app/bin/rackup +29 -0
- data/spec/fixtures/rails_users_app/bin/rails +4 -0
- data/spec/fixtures/rails_users_app/bin/rake +29 -0
- data/spec/fixtures/rails_users_app/bin/rspec +29 -0
- data/spec/fixtures/rails_users_app/bin/ruby-parse +29 -0
- data/spec/fixtures/rails_users_app/bin/ruby-rewrite +29 -0
- data/spec/fixtures/rails_users_app/bin/sequel +29 -0
- data/spec/fixtures/rails_users_app/bin/setup +25 -0
- data/spec/fixtures/rails_users_app/bin/sprockets +29 -0
- data/spec/fixtures/rails_users_app/bin/thor +29 -0
- data/spec/fixtures/rails_users_app/bin/update +25 -0
- data/spec/fixtures/rails_users_app/config.ru +5 -0
- data/spec/fixtures/rails_users_app/config/application.rb +51 -0
- data/spec/fixtures/rails_users_app/config/boot.rb +3 -0
- data/spec/fixtures/rails_users_app/config/credentials.yml.enc +1 -0
- data/spec/fixtures/rails_users_app/config/database.yml +18 -0
- data/spec/fixtures/rails_users_app/config/environment.rb +5 -0
- data/spec/fixtures/rails_users_app/config/environments/development.rb +40 -0
- data/spec/fixtures/rails_users_app/config/environments/production.rb +68 -0
- data/spec/fixtures/rails_users_app/config/environments/test.rb +36 -0
- data/spec/fixtures/rails_users_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/fixtures/rails_users_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/fixtures/rails_users_app/config/initializers/cors.rb +16 -0
- data/spec/fixtures/rails_users_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/fixtures/rails_users_app/config/initializers/inflections.rb +16 -0
- data/spec/fixtures/rails_users_app/config/initializers/mime_types.rb +4 -0
- data/spec/fixtures/rails_users_app/config/initializers/record_button.rb +3 -0
- data/spec/fixtures/rails_users_app/config/initializers/wrap_parameters.rb +9 -0
- data/spec/fixtures/rails_users_app/config/locales/en.yml +33 -0
- data/spec/fixtures/rails_users_app/config/routes.rb +11 -0
- data/spec/fixtures/rails_users_app/create_app +27 -0
- data/spec/fixtures/rails_users_app/db/migrate/20190728211408_create_users.rb +9 -0
- data/spec/fixtures/rails_users_app/db/schema.rb +23 -0
- data/spec/fixtures/rails_users_app/docker-compose.yml +28 -0
- data/spec/fixtures/rails_users_app/features/api_users.feature +13 -0
- data/spec/fixtures/rails_users_app/features/support/env.rb +4 -0
- data/spec/fixtures/rails_users_app/features/support/hooks.rb +11 -0
- data/spec/fixtures/rails_users_app/features/support/steps.rb +18 -0
- data/spec/fixtures/rails_users_app/lib/tasks/.keep +0 -0
- data/spec/fixtures/rails_users_app/log/.keep +0 -0
- data/spec/fixtures/rails_users_app/public/robots.txt +1 -0
- data/spec/fixtures/rails_users_app/spec/controllers/users_controller_api_spec.rb +29 -0
- data/spec/fixtures/rails_users_app/spec/models/user_spec.rb +39 -0
- data/spec/fixtures/rails_users_app/spec/rails_helper.rb +66 -0
- data/spec/fixtures/rails_users_app/spec/spec_helper.rb +96 -0
- data/spec/fixtures/rails_users_app/users_app/.gitignore +20 -0
- data/spec/hook_spec.rb +576 -0
- data/spec/rails_spec_helper.rb +60 -0
- data/spec/railtie_spec.rb +44 -0
- data/spec/record_sql_rails4_pg_spec.rb +76 -0
- data/spec/record_sql_rails_pg_spec.rb +68 -0
- data/spec/remote_recording_spec.rb +117 -0
- data/spec/rspec_feature_metadata_spec.rb +32 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/util_spec.rb +21 -0
- data/test/cli_test.rb +116 -0
- data/test/cucumber_test.rb +72 -0
- data/test/fixtures/cli_record_test/appmap.yml +3 -0
- data/test/fixtures/cli_record_test/lib/cli_record_test/main.rb +9 -0
- data/test/fixtures/cucumber4_recorder/Gemfile +5 -0
- data/test/fixtures/cucumber4_recorder/appmap.yml +3 -0
- data/test/fixtures/cucumber4_recorder/features/say_hello.feature +5 -0
- data/test/fixtures/cucumber4_recorder/features/support/env.rb +5 -0
- data/test/fixtures/cucumber4_recorder/features/support/hooks.rb +11 -0
- data/test/fixtures/cucumber4_recorder/features/support/steps.rb +9 -0
- data/test/fixtures/cucumber4_recorder/lib/hello.rb +7 -0
- data/test/fixtures/cucumber_recorder/Gemfile +5 -0
- data/test/fixtures/cucumber_recorder/appmap.yml +3 -0
- data/test/fixtures/cucumber_recorder/features/say_hello.feature +5 -0
- data/test/fixtures/cucumber_recorder/features/support/env.rb +5 -0
- data/test/fixtures/cucumber_recorder/features/support/hooks.rb +11 -0
- data/test/fixtures/cucumber_recorder/features/support/steps.rb +9 -0
- data/test/fixtures/cucumber_recorder/lib/hello.rb +7 -0
- data/test/fixtures/minitest_recorder/Gemfile +5 -0
- data/test/fixtures/minitest_recorder/appmap.yml +3 -0
- data/test/fixtures/minitest_recorder/lib/hello.rb +5 -0
- data/test/fixtures/minitest_recorder/test/hello_test.rb +12 -0
- data/test/fixtures/process_recorder/appmap.yml +3 -0
- data/test/fixtures/process_recorder/hello.rb +9 -0
- data/test/fixtures/rspec_recorder/Gemfile +5 -0
- data/test/fixtures/rspec_recorder/appmap.yml +3 -0
- data/test/fixtures/rspec_recorder/lib/hello.rb +5 -0
- data/test/fixtures/rspec_recorder/spec/decorated_hello_spec.rb +21 -0
- data/test/fixtures/rspec_recorder/spec/labeled_hello_spec.rb +9 -0
- data/test/fixtures/rspec_recorder/spec/plain_hello_spec.rb +9 -0
- data/test/minitest_test.rb +38 -0
- data/test/record_process_test.rb +35 -0
- data/test/rspec_test.rb +82 -0
- data/test/test_helper.rb +4 -0
- metadata +525 -0
data/package.json
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"name": "appmap-ruby-lore",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "Lore for the AppMap Rubygem",
|
5
|
+
"scripts": {
|
6
|
+
"start": "./node_modules/applore/bin/lore serve"
|
7
|
+
},
|
8
|
+
"directories": {
|
9
|
+
"example": "examples",
|
10
|
+
"lib": "lib",
|
11
|
+
"test": "test"
|
12
|
+
},
|
13
|
+
"repository": {
|
14
|
+
"type": "git",
|
15
|
+
"url": "git+https://github.com/applandinc/appmap-ruby.git"
|
16
|
+
},
|
17
|
+
"bugs": {
|
18
|
+
"url": "https://github.com/applandinc/appmap-ruby/issues"
|
19
|
+
},
|
20
|
+
"homepage": "https://github.com/applandinc/appmap-ruby#readme",
|
21
|
+
"dependencies": {
|
22
|
+
"applore": "^0.3.0"
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'rails_spec_helper'
|
2
|
+
|
3
|
+
describe 'AbstractControllerBase' do
|
4
|
+
before(:all) { @fixture_dir = 'spec/fixtures/rails4_users_app' }
|
5
|
+
include_examples 'Rails app pg database'
|
6
|
+
|
7
|
+
around(:each) do |example|
|
8
|
+
FileUtils.rm_rf tmpdir
|
9
|
+
FileUtils.mkdir_p tmpdir
|
10
|
+
cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:8"
|
11
|
+
run_cmd cmd, chdir: @fixture_dir
|
12
|
+
|
13
|
+
example.run
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:tmpdir) { 'tmp/spec/AbstractControllerBase' }
|
17
|
+
let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
|
18
|
+
|
19
|
+
describe 'testing with rspec' do
|
20
|
+
it 'Message fields are recorded in the appmap' do
|
21
|
+
expect(File).to exist(appmap_json)
|
22
|
+
appmap = JSON.parse(File.read(appmap_json)).to_yaml
|
23
|
+
|
24
|
+
expect(appmap).to include(<<-MESSAGE.strip)
|
25
|
+
message:
|
26
|
+
- name: login
|
27
|
+
class: String
|
28
|
+
value: alice
|
29
|
+
object_id:
|
30
|
+
MESSAGE
|
31
|
+
|
32
|
+
expect(appmap).to include(<<-MESSAGE.strip)
|
33
|
+
- name: password
|
34
|
+
class: String
|
35
|
+
value: "[FILTERED]"
|
36
|
+
object_id:
|
37
|
+
MESSAGE
|
38
|
+
|
39
|
+
expect(appmap).to include(<<-SERVER_REQUEST.strip)
|
40
|
+
http_server_request:
|
41
|
+
request_method: POST
|
42
|
+
path_info: "/api/users?login=alice&password=foobar
|
43
|
+
SERVER_REQUEST
|
44
|
+
end
|
45
|
+
it 'Properly captures method parameters in the appmap' do
|
46
|
+
expect(File).to exist(appmap_json)
|
47
|
+
appmap = JSON.parse(File.read(appmap_json)).to_yaml
|
48
|
+
|
49
|
+
expect(appmap).to match(<<-CREATE_CALL.strip)
|
50
|
+
event: call
|
51
|
+
defined_class: Api::UsersController
|
52
|
+
method_id: build_user
|
53
|
+
path: app/controllers/api/users_controller.rb
|
54
|
+
lineno: 23
|
55
|
+
thread_id: .*
|
56
|
+
static: false
|
57
|
+
parameters:
|
58
|
+
- name: params
|
59
|
+
class: Hash
|
60
|
+
object_id: .*
|
61
|
+
value: '{"login"=>"alice"}'
|
62
|
+
kind: req
|
63
|
+
receiver:
|
64
|
+
CREATE_CALL
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'rails_spec_helper'
|
2
|
+
|
3
|
+
describe 'AbstractControllerBase' do
|
4
|
+
before(:all) { @fixture_dir = 'spec/fixtures/rails_users_app' }
|
5
|
+
include_context 'Rails app pg database'
|
6
|
+
|
7
|
+
around(:each) do |example|
|
8
|
+
FileUtils.rm_rf tmpdir
|
9
|
+
FileUtils.mkdir_p tmpdir
|
10
|
+
cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:8"
|
11
|
+
run_cmd cmd, chdir: @fixture_dir
|
12
|
+
|
13
|
+
example.run
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:tmpdir) { 'tmp/spec/AbstractControllerBase' }
|
17
|
+
let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
|
18
|
+
|
19
|
+
describe 'testing with rspec' do
|
20
|
+
it 'inventory file is printed' do
|
21
|
+
expect(File).to exist(File.join(tmpdir, 'appmap/rspec/Inventory.appmap.json'))
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'message fields are recorded in the appmap' do
|
25
|
+
expect(File).to exist(appmap_json)
|
26
|
+
appmap = JSON.parse(File.read(appmap_json)).to_yaml
|
27
|
+
|
28
|
+
expect(appmap).to include(<<-MESSAGE.strip)
|
29
|
+
message:
|
30
|
+
- name: login
|
31
|
+
class: String
|
32
|
+
value: alice
|
33
|
+
object_id:
|
34
|
+
MESSAGE
|
35
|
+
|
36
|
+
expect(appmap).to include(<<-MESSAGE.strip)
|
37
|
+
- name: password
|
38
|
+
class: String
|
39
|
+
value: "[FILTERED]"
|
40
|
+
object_id:
|
41
|
+
MESSAGE
|
42
|
+
|
43
|
+
expect(appmap).to include(<<-SERVER_REQUEST.strip)
|
44
|
+
http_server_request:
|
45
|
+
request_method: POST
|
46
|
+
path_info: "/api/users"
|
47
|
+
SERVER_REQUEST
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'Properly captures method parameters in the appmap' do
|
51
|
+
expect(File).to exist(appmap_json)
|
52
|
+
appmap = JSON.parse(File.read(appmap_json)).to_yaml
|
53
|
+
|
54
|
+
expect(appmap).to match(<<-CREATE_CALL.strip)
|
55
|
+
event: call
|
56
|
+
defined_class: Api::UsersController
|
57
|
+
method_id: build_user
|
58
|
+
path: app/controllers/api/users_controller.rb
|
59
|
+
lineno: 23
|
60
|
+
thread_id: .*
|
61
|
+
static: false
|
62
|
+
parameters:
|
63
|
+
- name: params
|
64
|
+
class: ActiveSupport::HashWithIndifferentAccess
|
65
|
+
object_id: .*
|
66
|
+
value: '{"login"=>"alice"}'
|
67
|
+
kind: req
|
68
|
+
receiver:
|
69
|
+
CREATE_CALL
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_spec_helper'
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
require 'appmap/config'
|
6
|
+
|
7
|
+
describe AppMap::Config, docker: false do
|
8
|
+
it 'loads from a Hash' do
|
9
|
+
config_data = {
|
10
|
+
name: 'test',
|
11
|
+
packages: [
|
12
|
+
{
|
13
|
+
path: 'path-1'
|
14
|
+
},
|
15
|
+
{
|
16
|
+
path: 'path-2',
|
17
|
+
exclude: [ 'exclude-1' ]
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}.deep_stringify_keys!
|
21
|
+
config = AppMap::Config.load(config_data)
|
22
|
+
|
23
|
+
expect(config.to_h.deep_stringify_keys!).to eq(config_data)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class InstanceMethod
|
4
|
+
def to_s
|
5
|
+
'Instance Method fixture'
|
6
|
+
end
|
7
|
+
|
8
|
+
def say_default
|
9
|
+
'default'
|
10
|
+
end
|
11
|
+
|
12
|
+
def say_echo(arg)
|
13
|
+
arg.to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
def say_kw(kw: 'kw')
|
17
|
+
kw.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def say_block(&block)
|
21
|
+
yield
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# From the manual page https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL.html
|
4
|
+
|
5
|
+
require 'openssl'
|
6
|
+
|
7
|
+
module OpenSSLExample
|
8
|
+
def OpenSSLExample.example
|
9
|
+
ca_key = OpenSSL::PKey::RSA.new 2048
|
10
|
+
pass_phrase = 'my secure pass phrase goes here'
|
11
|
+
|
12
|
+
cipher = OpenSSL::Cipher.new 'AES-256-CBC'
|
13
|
+
|
14
|
+
open 'tmp/ca_key.pem', 'w', 0644 do |io|
|
15
|
+
io.write ca_key.export(cipher, pass_phrase)
|
16
|
+
end
|
17
|
+
|
18
|
+
ca_name = OpenSSL::X509::Name.parse '/CN=ca/DC=example'
|
19
|
+
|
20
|
+
ca_cert = OpenSSL::X509::Certificate.new
|
21
|
+
ca_cert.serial = 0
|
22
|
+
ca_cert.version = 2
|
23
|
+
ca_cert.not_before = Time.now
|
24
|
+
ca_cert.not_after = Time.now + 86400
|
25
|
+
|
26
|
+
ca_cert.public_key = ca_key.public_key
|
27
|
+
ca_cert.subject = ca_name
|
28
|
+
ca_cert.issuer = ca_name
|
29
|
+
|
30
|
+
extension_factory = OpenSSL::X509::ExtensionFactory.new
|
31
|
+
extension_factory.subject_certificate = ca_cert
|
32
|
+
extension_factory.issuer_certificate = ca_cert
|
33
|
+
|
34
|
+
ca_cert.add_extension extension_factory.create_extension('subjectKeyIdentifier', 'hash')
|
35
|
+
ca_cert.add_extension extension_factory.create_extension('basicConstraints', 'CA:TRUE', true)
|
36
|
+
|
37
|
+
ca_cert.add_extension extension_factory.create_extension(
|
38
|
+
'keyUsage', 'cRLSign,keyCertSign', true)
|
39
|
+
|
40
|
+
ca_cert.sign ca_key, OpenSSL::Digest::SHA1.new
|
41
|
+
|
42
|
+
open 'tmp/ca_cert.pem', 'w' do |io|
|
43
|
+
io.write ca_cert.to_pem
|
44
|
+
end
|
45
|
+
|
46
|
+
csr = OpenSSL::X509::Request.new
|
47
|
+
csr.version = 0
|
48
|
+
csr.subject = OpenSSL::X509::Name.new([ ['CN', 'the name to sign', OpenSSL::ASN1::UTF8STRING] ])
|
49
|
+
csr.public_key = ca_key.public_key
|
50
|
+
csr.sign ca_key, OpenSSL::Digest::SHA1.new
|
51
|
+
|
52
|
+
open 'tmp/csr.pem', 'w' do |io|
|
53
|
+
io.write csr.to_pem
|
54
|
+
end
|
55
|
+
|
56
|
+
csr = OpenSSL::X509::Request.new File.read 'tmp/csr.pem'
|
57
|
+
|
58
|
+
raise 'CSR can not be verified' unless csr.verify csr.public_key
|
59
|
+
|
60
|
+
csr_cert = OpenSSL::X509::Certificate.new
|
61
|
+
csr_cert.serial = 0
|
62
|
+
csr_cert.version = 2
|
63
|
+
csr_cert.not_before = Time.now
|
64
|
+
csr_cert.not_after = Time.now + 600
|
65
|
+
|
66
|
+
csr_cert.subject = csr.subject
|
67
|
+
csr_cert.public_key = csr.public_key
|
68
|
+
csr_cert.issuer = ca_cert.subject
|
69
|
+
|
70
|
+
extension_factory = OpenSSL::X509::ExtensionFactory.new
|
71
|
+
extension_factory.subject_certificate = csr_cert
|
72
|
+
extension_factory.issuer_certificate = ca_cert
|
73
|
+
|
74
|
+
csr_cert.add_extension extension_factory.create_extension('basicConstraints', 'CA:FALSE')
|
75
|
+
|
76
|
+
csr_cert.add_extension extension_factory.create_extension(
|
77
|
+
'keyUsage', 'keyEncipherment,dataEncipherment,digitalSignature')
|
78
|
+
|
79
|
+
csr_cert.add_extension extension_factory.create_extension('subjectKeyIdentifier', 'hash')
|
80
|
+
|
81
|
+
csr_cert.sign ca_key, OpenSSL::Digest::SHA1.new
|
82
|
+
|
83
|
+
open 'tmp/csr_cert.pem', 'w' do |io|
|
84
|
+
io.write csr_cert.to_pem
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SingletonMethod
|
4
|
+
class << self
|
5
|
+
def say_default
|
6
|
+
'default'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def SingletonMethod.say_class_defined
|
11
|
+
'defined with explicit class scope'
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.say_self_defined
|
15
|
+
'defined with self class scope'
|
16
|
+
end
|
17
|
+
|
18
|
+
# When called, do_include calls +include+ to bring in the module
|
19
|
+
# AddMethod. AddMethod defines a new instance method, which gets
|
20
|
+
# added to the singleton class of SingletonMethod.
|
21
|
+
def do_include
|
22
|
+
class << self
|
23
|
+
SingletonMethod.include(AddMethod)
|
24
|
+
end
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.new_with_instance_method
|
29
|
+
SingletonMethod.new.tap do |m|
|
30
|
+
def m.say_instance_defined
|
31
|
+
'defined for an instance'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
'Singleton Method fixture'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
module AddMethod
|
42
|
+
def self.included(base)
|
43
|
+
base.module_eval do
|
44
|
+
define_method "added_method" do
|
45
|
+
_added_method
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def _added_method
|
51
|
+
'defined by including a module'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
ARG GEM_VERSION
|
2
|
+
ARG RUBY_VERSION
|
3
|
+
|
4
|
+
FROM appmap:${GEM_VERSION} as appmap
|
5
|
+
|
6
|
+
FROM ruby:${RUBY_VERSION}
|
7
|
+
RUN apt-get update && apt-get install -y vim less
|
8
|
+
|
9
|
+
RUN mkdir /app
|
10
|
+
WORKDIR /app
|
11
|
+
|
12
|
+
RUN gem install -N bundler
|
13
|
+
|
14
|
+
COPY Gemfile .
|
15
|
+
|
16
|
+
RUN bundle
|
17
|
+
RUN bundle binstubs rack
|
18
|
+
|
19
|
+
COPY . .
|
20
|
+
|
21
|
+
COPY --from=appmap /pkg/appmap.gem /tmp/
|
22
|
+
RUN gem install /tmp/appmap.gem && \
|
23
|
+
bundle update --local appmap && \
|
24
|
+
bundle binstubs appmap --force
|
25
|
+
|
26
|
+
EXPOSE 9292
|
27
|
+
|
28
|
+
ENV GLI_DEBUG=true
|
29
|
+
|
30
|
+
ENTRYPOINT [ "./bin/appmap", "record", "-o", "tmp/appmap.json" ]
|
31
|
+
|
32
|
+
HEALTHCHECK --interval=1s --retries=10 CMD curl --fail http://localhost:9292/health || exit 1
|