From 0f83cb17058b4bfff7f604910f76c2aa2d401ccb Mon Sep 17 00:00:00 2001 From: Miguel Savignano Date: Fri, 1 Nov 2019 22:26:49 +0100 Subject: [PATCH] refactor test --- spec/fixtures/input.json | 107 -------------------- spec/fixtures/{ => output}/annotations.json | 0 spec/fixtures/{ => output}/summary.md | 0 spec/report_adapter_spec.rb | 8 +- 4 files changed, 6 insertions(+), 109 deletions(-) delete mode 100644 spec/fixtures/input.json rename spec/fixtures/{ => output}/annotations.json (100%) rename spec/fixtures/{ => output}/summary.md (100%) diff --git a/spec/fixtures/input.json b/spec/fixtures/input.json deleted file mode 100644 index ee03e71..0000000 --- a/spec/fixtures/input.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "scan_info": { - "app_path": "/home/miguemasx/developer/dockerize-rails", - "rails_version": "5.2.2", - "security_warnings": 1, - "start_time": "2019-10-25 11:25:31 +0200", - "end_time": "2019-10-25 11:25:31 +0200", - "duration": 0.108293375, - "checks_performed": [ - "BasicAuth", - "BasicAuthTimingAttack", - "ContentTag", - "CookieSerialization", - "CreateWith", - "CrossSiteScripting", - "DefaultRoutes", - "Deserialize", - "DetailedExceptions", - "DigestDoS", - "DynamicFinders", - "EscapeFunction", - "Evaluation", - "Execute", - "FileAccess", - "FileDisclosure", - "FilterSkipping", - "ForgerySetting", - "HeaderDoS", - "I18nXSS", - "JRubyXML", - "JSONEncoding", - "JSONParsing", - "LinkTo", - "LinkToHref", - "MailTo", - "MassAssignment", - "MimeTypeDoS", - "ModelAttrAccessible", - "ModelAttributes", - "ModelSerialize", - "NestedAttributes", - "NestedAttributesBypass", - "NumberToCurrency", - "PermitAttributes", - "QuoteTableName", - "Redirect", - "RegexDoS", - "Render", - "RenderDoS", - "RenderInline", - "ResponseSplitting", - "RouteDoS", - "SQL", - "SQLCVEs", - "SSLVerify", - "SafeBufferManipulation", - "SanitizeMethods", - "SelectTag", - "SelectVulnerability", - "Send", - "SendFile", - "SessionManipulation", - "SessionSettings", - "SimpleFormat", - "SingleQuotes", - "SkipBeforeFilter", - "SprocketsPathTraversal", - "StripTags", - "SymbolDoSCVE", - "TranslateBug", - "UnsafeReflection", - "ValidationRegex", - "WithoutProtection", - "XMLDoS", - "YAMLParsing" - ], - "number_of_controllers": 2, - "number_of_models": 2, - "number_of_templates": 7, - "ruby_version": "2.6.3", - "brakeman_version": "4.7.0" - }, - "warnings": [ - { - "warning_type": "Mass Assignment", - "warning_code": 70, - "fingerprint": "5b486a498b14e1a12361c50863e2770c966799c9d5c6b6b9ab9bd8797c28a986", - "check_name": "MassAssignment", - "message": "Parameters should be whitelisted for mass assignment", - "file": "app/controllers/posts_controller.rb", - "line": 17, - "link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/", - "code": "params.permit!", - "render_path": null, - "location": { - "type": "method", - "class": "PostsController", - "method": "new" - }, - "user_input": null, - "confidence": "High" - } - ], - "ignored_warnings": [], - "errors": [], - "obsolete": [] -} diff --git a/spec/fixtures/annotations.json b/spec/fixtures/output/annotations.json similarity index 100% rename from spec/fixtures/annotations.json rename to spec/fixtures/output/annotations.json diff --git a/spec/fixtures/summary.md b/spec/fixtures/output/summary.md similarity index 100% rename from spec/fixtures/summary.md rename to spec/fixtures/output/summary.md diff --git a/spec/report_adapter_spec.rb b/spec/report_adapter_spec.rb index 7d72216..132dec7 100644 --- a/spec/report_adapter_spec.rb +++ b/spec/report_adapter_spec.rb @@ -8,7 +8,11 @@ describe ReportAdapter do end let(:spec_annotations) do - JSON(File.read('./spec/fixtures/annotations.json')) + JSON(File.read('./spec/fixtures/output/annotations.json')) + end + + let(:spec_summary) do + File.read('./spec/fixtures/output/summary.md') end let(:adapter) { ReportAdapter } @@ -20,7 +24,7 @@ describe ReportAdapter do it '.summary' do result = adapter.summary(brakeman_report) - expect(result).to be_a(String) + expect(result).to eq(spec_summary) end it '.annotations' do