api-tester 1.0.0 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/dependabot.yml +29 -0
- data/.github/workflows/push.yml +39 -0
- data/.github/workflows/test.yml +31 -0
- data/.rubocop.yml +171 -0
- data/Gemfile +2 -0
- data/Guardfile +70 -0
- data/README.md +65 -61
- data/Rakefile +8 -3
- data/api-tester.gemspec +28 -24
- data/changelog.txt +10 -0
- data/lib/api-tester/config.rb +17 -15
- data/lib/api-tester/definition/boundary_case.rb +5 -4
- data/lib/api-tester/definition/contract.rb +10 -5
- data/lib/api-tester/definition/endpoint.rb +58 -32
- data/lib/api-tester/definition/fields/array_field.rb +26 -21
- data/lib/api-tester/definition/fields/boolean_field.rb +17 -7
- data/lib/api-tester/definition/fields/email_field.rb +28 -11
- data/lib/api-tester/definition/fields/enum_field.rb +19 -12
- data/lib/api-tester/definition/fields/field.rb +52 -45
- data/lib/api-tester/definition/fields/number_field.rb +20 -6
- data/lib/api-tester/definition/fields/object_field.rb +37 -30
- data/lib/api-tester/definition/fields/plain_array_field.rb +25 -0
- data/lib/api-tester/definition/method.rb +8 -5
- data/lib/api-tester/definition/request.rb +43 -19
- data/lib/api-tester/definition/response.rb +35 -25
- data/lib/api-tester/method_case_test.rb +68 -54
- data/lib/api-tester/modules/benchmark_module.rb +35 -0
- data/lib/api-tester/modules/extra_verbs.rb +36 -10
- data/lib/api-tester/modules/format.rb +23 -7
- data/lib/api-tester/modules/good_case.rb +25 -10
- data/lib/api-tester/modules/good_variations.rb +69 -0
- data/lib/api-tester/modules/injection_module.rb +44 -23
- data/lib/api-tester/modules/missing_resource.rb +63 -0
- data/lib/api-tester/modules/required_fields.rb +51 -0
- data/lib/api-tester/modules/server_information.rb +14 -12
- data/lib/api-tester/modules/typo.rb +39 -14
- data/lib/api-tester/modules/unexpected_fields.rb +59 -0
- data/lib/api-tester/modules/unused_fields.rb +13 -7
- data/lib/api-tester/reporter/api_report.rb +25 -16
- data/lib/api-tester/reporter/missing_field_report.rb +11 -15
- data/lib/api-tester/reporter/report.rb +12 -13
- data/lib/api-tester/reporter/response_time_report.rb +24 -0
- data/lib/api-tester/reporter/status_code_report.rb +10 -4
- data/lib/api-tester/test_helper.rb +8 -6
- data/lib/api-tester/util/response_evaluator.rb +84 -56
- data/lib/api-tester/util/supported_verbs.rb +8 -5
- data/lib/api-tester/version.rb +3 -1
- data/lib/api-tester.rb +6 -3
- metadata +92 -27
- data/.travis.yml +0 -6
- data/lib/api-tester/reporter/missing_response_field_report.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1a006651b7f9b476bc20e110d944645da7b55bdec80cb15a7edd6ce670f5afe8
|
4
|
+
data.tar.gz: e3f528f018ba5bee1a300f180667292a863f1774484df7a2f9023fb260cb9053
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 699c3b1c2df0fcaba5e5ce2dc01107f341e3f5a5a4b8a2b604619de7118df616b2eb8aff5957408f551dafa0f682db1e3edc801d62863714e9e31fefc3211256
|
7
|
+
data.tar.gz: b38b8e38b0a8f4945408033c141bf52ae86afbfb78c9d3a804022632f230515cf04e38efbb151c3f48c950b9c782fff83a5ab98583e95b7789a859e96b144fe1
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Set update schedule for GitHub Actions
|
2
|
+
|
3
|
+
version: 2
|
4
|
+
updates:
|
5
|
+
|
6
|
+
- package-ecosystem: "github-actions"
|
7
|
+
directory: "/"
|
8
|
+
schedule:
|
9
|
+
# Check for updates to GitHub Actions every weekday
|
10
|
+
interval: "daily"
|
11
|
+
|
12
|
+
- package-ecosystem: "bundler"
|
13
|
+
directory: '/'
|
14
|
+
schedule:
|
15
|
+
interval: 'daily'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: Dependabot Auto Merge
|
2
|
+
|
3
|
+
permissions:
|
4
|
+
pull-requests: write
|
5
|
+
contents: write
|
6
|
+
|
7
|
+
on:
|
8
|
+
pull_request:
|
9
|
+
# Allows you to run this workflow manually from the Actions tab
|
10
|
+
workflow_dispatch:
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
dependabot:
|
14
|
+
# The type of runner that the job will run on
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
if: ${{ github.actor == 'dependabot[bot]' }}
|
17
|
+
# Steps represent a sequence of tasks that will be executed as part of the job
|
18
|
+
steps:
|
19
|
+
- name: Dependabot metadata
|
20
|
+
id: metadata
|
21
|
+
uses: dependabot/fetch-metadata@v1.3.3
|
22
|
+
with:
|
23
|
+
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
24
|
+
|
25
|
+
- name: Enable auto-merge for Dependabot patch update PRs
|
26
|
+
run: gh pr merge --auto --merge "$PR_URL"
|
27
|
+
env:
|
28
|
+
PR_URL: ${{github.event.pull_request.html_url}}
|
29
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
name: Publish Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
name: Build + Publish
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v3
|
13
|
+
- name: Set up Ruby 2.6
|
14
|
+
uses: actions/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: 2.6.x
|
17
|
+
|
18
|
+
- name: Publish to RubyGems
|
19
|
+
run: |
|
20
|
+
mkdir -p $HOME/.gem
|
21
|
+
touch $HOME/.gem/credentials
|
22
|
+
chmod 0600 $HOME/.gem/credentials
|
23
|
+
printf -- "---\n:rubygems: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
24
|
+
gem build *.gemspec
|
25
|
+
gem push --KEY rubygems --host https://rubygems.org *.gem
|
26
|
+
env:
|
27
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
28
|
+
|
29
|
+
- name: Publish to GPR
|
30
|
+
run: |
|
31
|
+
mkdir -p $HOME/.gem
|
32
|
+
touch $HOME/.gem/credentials
|
33
|
+
chmod 0600 $HOME/.gem/credentials
|
34
|
+
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
35
|
+
gem build *.gemspec
|
36
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
37
|
+
env:
|
38
|
+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
39
|
+
OWNER: ${{ github.repository_owner }}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Test
|
9
|
+
|
10
|
+
on: [push]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v3
|
19
|
+
- name: Set up Ruby
|
20
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
21
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
22
|
+
# uses: ruby/setup-ruby@v1
|
23
|
+
uses: ruby/setup-ruby@08245253a76fa4d1e459b7809579c62bd9eb718a
|
24
|
+
with:
|
25
|
+
ruby-version: 2.6
|
26
|
+
- name: Install dependencies
|
27
|
+
run: bundle install
|
28
|
+
- name: Run lint
|
29
|
+
run: bundle exec rake rubocop
|
30
|
+
- name: Run tests
|
31
|
+
run: bundle exec rake spec
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
Exclude:
|
4
|
+
- 'Guardfile'
|
5
|
+
- '*.gemspec'
|
6
|
+
- 'Rakefile'
|
7
|
+
- '**/*.rake'
|
8
|
+
- 'bin/*'
|
9
|
+
|
10
|
+
Gemspec/RequireMFA:
|
11
|
+
Enabled: true
|
12
|
+
Gemspec/DeprecatedAttributeAssignment: # (new in 1.10)
|
13
|
+
Enabled: true
|
14
|
+
Layout/LineContinuationLeadingSpace:
|
15
|
+
Enabled: true
|
16
|
+
Layout/LineContinuationSpacing:
|
17
|
+
Enabled: true
|
18
|
+
Layout/LineEndStringConcatenationIndentation:
|
19
|
+
Enabled: true
|
20
|
+
Layout/SpaceBeforeBrackets: # (new in 1.7)
|
21
|
+
Enabled: true
|
22
|
+
Lint/AmbiguousAssignment: # (new in 1.7)
|
23
|
+
Enabled: true
|
24
|
+
Lint/DeprecatedConstants: # (new in 1.8)
|
25
|
+
Enabled: true
|
26
|
+
Lint/DuplicateBranch: # (new in 1.3)
|
27
|
+
Enabled: false
|
28
|
+
Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
|
29
|
+
Enabled: true
|
30
|
+
Lint/EmptyBlock: # (new in 1.1)
|
31
|
+
Enabled: true
|
32
|
+
Lint/EmptyClass: # (new in 1.3)
|
33
|
+
Enabled: true
|
34
|
+
Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
|
35
|
+
Enabled: true
|
36
|
+
Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
|
37
|
+
Enabled: true
|
38
|
+
Lint/NumberedParameterAssignment: # (new in 1.9)
|
39
|
+
Enabled: true
|
40
|
+
Lint/OrAssignmentToConstant: # (new in 1.9)
|
41
|
+
Enabled: true
|
42
|
+
Lint/RedundantDirGlobSort: # (new in 1.8)
|
43
|
+
Enabled: true
|
44
|
+
Lint/SymbolConversion: # (new in 1.9)
|
45
|
+
Enabled: true
|
46
|
+
Lint/ToEnumArguments: # (new in 1.1)
|
47
|
+
Enabled: true
|
48
|
+
Lint/TripleQuotes: # (new in 1.9)
|
49
|
+
Enabled: true
|
50
|
+
Lint/UnexpectedBlockArity: # (new in 1.5)
|
51
|
+
Enabled: true
|
52
|
+
Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
|
53
|
+
Enabled: true
|
54
|
+
Lint/AmbiguousOperatorPrecedence:
|
55
|
+
Enabled: true
|
56
|
+
Lint/AmbiguousRange:
|
57
|
+
Enabled: true
|
58
|
+
Lint/ConstantOverwrittenInRescue:
|
59
|
+
Enabled: true
|
60
|
+
Lint/EmptyInPattern: # new in 1.16
|
61
|
+
Enabled: true
|
62
|
+
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
|
63
|
+
Enabled: true
|
64
|
+
Lint/NonAtomicFileOperation: # new in 1.31
|
65
|
+
Enabled: true
|
66
|
+
Lint/RefinementImportMethods: # new in 1.27
|
67
|
+
Enabled: true
|
68
|
+
Lint/RequireRelativeSelfPath: # new in 1.22
|
69
|
+
Enabled: true
|
70
|
+
Lint/UselessRuby2Keywords: # new in 1.23
|
71
|
+
Enabled: true
|
72
|
+
Lint/BooleanSymbol:
|
73
|
+
Enabled: false
|
74
|
+
Metrics/BlockLength:
|
75
|
+
Enabled: false
|
76
|
+
Metrics/MethodLength:
|
77
|
+
Enabled: false
|
78
|
+
Layout/LineLength:
|
79
|
+
Enabled: false
|
80
|
+
Metrics/AbcSize:
|
81
|
+
Enabled: false
|
82
|
+
Metrics/PerceivedComplexity:
|
83
|
+
Enabled: false
|
84
|
+
Metrics/CyclomaticComplexity:
|
85
|
+
Enabled: false
|
86
|
+
Metrics/ParameterLists:
|
87
|
+
Enabled: false
|
88
|
+
Naming/BlockForwarding: # new in 1.24
|
89
|
+
Enabled: true
|
90
|
+
Naming/PredicateName:
|
91
|
+
Enabled: false
|
92
|
+
Naming/FileName:
|
93
|
+
Enabled: false
|
94
|
+
Security/CompoundHash: # new in 1.28
|
95
|
+
Enabled: true
|
96
|
+
Security/IoMethods: # new in 1.22
|
97
|
+
Enabled: true
|
98
|
+
Style/EnvHome: # new in 1.29
|
99
|
+
Enabled: true
|
100
|
+
Style/FetchEnvVar: # new in 1.28
|
101
|
+
Enabled: true
|
102
|
+
Style/FileRead: # new in 1.24
|
103
|
+
Enabled: true
|
104
|
+
Style/FileWrite: # new in 1.24
|
105
|
+
Enabled: true
|
106
|
+
Style/InPatternThen: # new in 1.16
|
107
|
+
Enabled: true
|
108
|
+
Style/MapCompactWithConditionalBlock: # new in 1.30
|
109
|
+
Enabled: true
|
110
|
+
Style/MapToHash: # new in 1.24
|
111
|
+
Enabled: true
|
112
|
+
Style/MultilineInPatternThen: # new in 1.16
|
113
|
+
Enabled: true
|
114
|
+
Style/NestedFileDirname: # new in 1.26
|
115
|
+
Enabled: true
|
116
|
+
Style/NumberedParameters: # new in 1.22
|
117
|
+
Enabled: true
|
118
|
+
Style/NumberedParametersLimit: # new in 1.22
|
119
|
+
Enabled: true
|
120
|
+
Style/ObjectThen: # new in 1.28
|
121
|
+
Enabled: true
|
122
|
+
Style/OpenStructUse: # new in 1.23
|
123
|
+
Enabled: true
|
124
|
+
Style/QuotedSymbols: # new in 1.16
|
125
|
+
Enabled: true
|
126
|
+
Style/RedundantInitialize: # new in 1.27
|
127
|
+
Enabled: false
|
128
|
+
Style/RedundantSelfAssignmentBranch: # new in 1.19
|
129
|
+
Enabled: true
|
130
|
+
Style/SelectByRegexp: # new in 1.22
|
131
|
+
Enabled: true
|
132
|
+
Style/IfUnlessModifier:
|
133
|
+
Enabled: false
|
134
|
+
Style/NilComparison:
|
135
|
+
Enabled: false
|
136
|
+
Style/NumericPredicate:
|
137
|
+
Enabled: false
|
138
|
+
Style/MultipleComparison:
|
139
|
+
Enabled: false
|
140
|
+
Style/BlockDelimiters:
|
141
|
+
Enabled: false
|
142
|
+
Style/EmptyLiteral:
|
143
|
+
Enabled: false
|
144
|
+
Style/GuardClause:
|
145
|
+
Enabled: false
|
146
|
+
Style/FrozenStringLiteralComment:
|
147
|
+
Enabled: false
|
148
|
+
Style/ArgumentsForwarding: # (new in 1.1)
|
149
|
+
Enabled: true
|
150
|
+
Style/CollectionCompact: # (new in 1.2)
|
151
|
+
Enabled: true
|
152
|
+
Style/DocumentDynamicEvalDefinition: # (new in 1.1)
|
153
|
+
Enabled: true
|
154
|
+
Style/EndlessMethod: # (new in 1.8)
|
155
|
+
Enabled: true
|
156
|
+
Style/HashConversion: # (new in 1.10)
|
157
|
+
Enabled: true
|
158
|
+
Style/HashExcept: # (new in 1.7)
|
159
|
+
Enabled: true
|
160
|
+
Style/IfWithBooleanLiteralBranches: # (new in 1.9)
|
161
|
+
Enabled: true
|
162
|
+
Style/NegatedIfElseCondition: # (new in 1.2)
|
163
|
+
Enabled: true
|
164
|
+
Style/NilLambda: # (new in 1.3)
|
165
|
+
Enabled: true
|
166
|
+
Style/RedundantArgument: # (new in 1.4)
|
167
|
+
Enabled: true
|
168
|
+
Style/StringChars: # (new in 1.12)
|
169
|
+
Enabled: true
|
170
|
+
Style/SwapValues:
|
171
|
+
Enabled: true
|
data/Gemfile
CHANGED
data/Guardfile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
# Rails files
|
44
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
45
|
+
dsl.watch_spec_files_for(rails.app_files)
|
46
|
+
dsl.watch_spec_files_for(rails.views)
|
47
|
+
|
48
|
+
watch(rails.controllers) do |m|
|
49
|
+
[
|
50
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
51
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
52
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Rails config changes
|
57
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
58
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
59
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
60
|
+
|
61
|
+
# Capybara features specs
|
62
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
63
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
64
|
+
|
65
|
+
# Turnip features and steps
|
66
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
67
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
68
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
69
|
+
end
|
70
|
+
end
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Api::Tester
|
2
|
+
|
2
3
|
[![Gem Version](https://badge.fury.io/rb/api-tester.svg)](https://badge.fury.io/rb/api-tester)
|
3
|
-
[![Build Status](https://
|
4
|
+
[![Build Status](https://github.com/araneforseti/api-tester/workflows/Test/badge.svg)](https://github.com/araneforseti/api-tester/actions?query=workflow%3ATest+branch%3Amaster)
|
4
5
|
|
5
6
|
Work in Progress! Use at own risk, definitely not ready
|
6
7
|
for prime time! To isolate your project from the changes, be sure to specify which gem version you use.
|
@@ -13,73 +14,41 @@ relates to the unpublished gem version actively under development
|
|
13
14
|
|
14
15
|
Check out [API Tester Example](https://github.com/araneforseti/example_api-tester) for an example in action
|
15
16
|
|
16
|
-
|
17
|
-
## Under Development
|
18
|
-
Check out our [Trello Board](https://trello.com/b/R3RtsJ2A/api-tester) to see progress and where we are headed!
|
19
|
-
Feel free to leave feedback through github's issue tracker
|
20
|
-
|
21
|
-
- Format module:
|
22
|
-
- Checks syntax problems with the request and
|
23
|
-
ensuring a consistent response
|
24
|
-
- Typo module:
|
25
|
-
- Tests simulates typos in the url
|
26
|
-
- Extra Verbs module:
|
27
|
-
- Checks all the supported verbs to ensure no vulnerabilities are exposed
|
28
|
-
- Good Case (name pending) module:
|
29
|
-
- Checks expected good requests will work
|
30
|
-
(eg, number field should accept integers
|
31
|
-
between 1 - 100)
|
32
|
-
- Unused Fields module:
|
33
|
-
- A module which runs after all the others and reports on any response fields which were never returned
|
34
|
-
|
35
|
-
## Intended Features Before "Release"
|
36
|
-
|
37
|
-
- Other Param Testing
|
38
|
-
- Path params
|
39
|
-
- Query
|
40
|
-
- Headers
|
41
|
-
- Endpoint Testing
|
42
|
-
- Unused Response Fields
|
43
|
-
- Invalid method names
|
44
|
-
- Invalid method types
|
45
|
-
- Documentation
|
46
|
-
- Generate Swagger-compliant documentation
|
47
|
-
- Generate definitions from Swagger documentation
|
17
|
+
## Out of Project Scope
|
48
18
|
|
49
|
-
|
19
|
+
- Logic testing (eg, if X is between A and B, then Y is required)
|
50
20
|
|
51
|
-
|
52
|
-
required)
|
21
|
+
## Usage
|
53
22
|
|
54
|
-
|
55
|
-
## Installation
|
23
|
+
### Installation
|
56
24
|
|
57
25
|
Add this line to your application's Gemfile (Note: specify your version due to gem's currently volatile nature):
|
58
26
|
|
59
27
|
```ruby
|
60
|
-
gem 'api-tester', '0.0
|
28
|
+
gem 'api-tester', '1.0.0'
|
61
29
|
```
|
62
30
|
|
63
31
|
And then execute:
|
64
32
|
|
65
|
-
|
33
|
+
bundle
|
66
34
|
|
67
35
|
Or install it yourself as:
|
68
36
|
|
69
|
-
|
37
|
+
gem install api-tester
|
70
38
|
|
71
|
-
|
39
|
+
### Usage in Code
|
72
40
|
|
73
41
|
Warning: This gem is still in alpha stage. Use at own risk
|
74
42
|
understanding the contract will change until the first
|
75
43
|
stable release
|
76
44
|
|
77
45
|
Define your contract and endpoints using
|
46
|
+
|
78
47
|
```ruby
|
79
48
|
require 'api-tester/definition/contract'
|
80
49
|
require 'api-tester/definition/endpoint'
|
81
|
-
contract = ApiTester::Contract.new "API Name"
|
82
|
-
endpoint = ApiTester::Endpoint.new "Some name which is currently unused", "
|
50
|
+
contract = ApiTester::Contract.new "API Name", "http://yourbase.com/api"
|
51
|
+
endpoint = ApiTester::Endpoint.new "Some name which is currently unused", "/endpoint"
|
83
52
|
```
|
84
53
|
|
85
54
|
Define methods on endpoints
|
@@ -87,38 +56,44 @@ Define methods on endpoints
|
|
87
56
|
```ruby
|
88
57
|
endpoint.add_method ApiTester::SupportedVerbs::GET, expected_response, expected_request
|
89
58
|
```
|
59
|
+
|
90
60
|
Note: While an extensive list of verbs exists in ApiTester::SupportedVerbs, you can define your own (with the caveat they have to be supported by RestClient)
|
91
61
|
|
92
62
|
Define fields used by the method (both Request and Response)
|
63
|
+
|
93
64
|
```ruby
|
94
65
|
expected_request = Request.new.add_field(ApiTester::Field.new "fieldName")
|
95
66
|
```
|
67
|
+
|
96
68
|
Note: Similar to methods, you can create your own fields.
|
97
|
-
They need to
|
69
|
+
They need to respond to:
|
70
|
+
|
98
71
|
```ruby
|
99
72
|
field.has_subfields?
|
100
73
|
values_array = field.negative_boundary_values
|
101
74
|
```
|
102
75
|
|
103
76
|
Define which modules you want to use through a config
|
77
|
+
|
104
78
|
```ruby
|
105
79
|
config = ApiTester::Config().with_module(Format)
|
106
80
|
```
|
107
81
|
|
108
82
|
Put them together and call go and off you go!
|
83
|
+
|
109
84
|
```ruby
|
110
85
|
request = ApiTester::Request.new.add_field(ApiTester::Field.new "fieldName")
|
111
86
|
expected_response = ApiTester::Response.new(200).add_field(ApiTester::Field.new "fieldName")
|
112
|
-
endpoint = ApiTester::Endpoint.new "Unused Name", "
|
87
|
+
endpoint = ApiTester::Endpoint.new "Unused Name", "/endpoint"
|
113
88
|
endpoint.add_method ApiTester::SupportedVerbs::GET, expected_response, request
|
114
|
-
contract = Contract.new "API Name"
|
89
|
+
contract = Contract.new "API Name", "http://yourbase.com/api"
|
115
90
|
contract.add_endpoint endpoint
|
116
91
|
config = ApiTester::Config().with_module(Format)
|
117
92
|
expect(ApiTester.go(contract, config)).to be true
|
118
93
|
|
119
94
|
```
|
120
95
|
|
121
|
-
|
96
|
+
### Dependencies
|
122
97
|
|
123
98
|
If any of your API endpoints have some setup which needs to happen before or after each call (eg, path param represents resource which needs to be created), you can use the TestHelper interface:
|
124
99
|
|
@@ -142,39 +117,55 @@ endpoint.test_helper = InfoCreator.new
|
|
142
117
|
expect(tester.go).to be true
|
143
118
|
```
|
144
119
|
|
145
|
-
|
146
|
-
|
120
|
+
## Modules
|
121
|
+
|
122
|
+
### Boundary
|
123
|
+
|
147
124
|
This module will test out various edge cases and
|
148
125
|
ensure error handling is consistent
|
149
126
|
|
150
|
-
|
127
|
+
### Good Case
|
128
|
+
|
151
129
|
This module ensures your 'default request' works
|
152
130
|
appropriately
|
153
131
|
|
154
|
-
|
132
|
+
### Typo
|
133
|
+
|
155
134
|
This module checks for common integration issues when an
|
156
135
|
API is first being worked against such as urls which don't
|
157
136
|
exist
|
158
137
|
|
159
|
-
|
138
|
+
### Extra Verbs
|
139
|
+
|
160
140
|
This module checks to ensure consistency in response when
|
161
141
|
the api receives verbs it doesn't explicitly support
|
162
142
|
|
163
|
-
|
143
|
+
### Unused Fields
|
144
|
+
|
164
145
|
If any response fields are not returned during tests run
|
165
146
|
by previous modules, this will fail with a report
|
166
147
|
detailing unreturned response fields. When using this
|
167
148
|
module, it is recommended the good case module is also
|
168
149
|
used.
|
169
150
|
|
170
|
-
|
151
|
+
### Required Fields
|
152
|
+
|
153
|
+
This module tests out all the various invalid combinations of required fields to ensure consistent response
|
154
|
+
|
155
|
+
### Unexpected Fields
|
156
|
+
|
157
|
+
This module calls out if the API returns anything unexpected in its response
|
158
|
+
|
159
|
+
### Custom Modules
|
160
|
+
|
171
161
|
Do you want to do something with the definition which this gem currently does not support?
|
172
162
|
You can create your own test module and add it to the config instance class!
|
173
163
|
Just make sure it adheres to the following interface:
|
164
|
+
|
174
165
|
```ruby
|
175
166
|
module CustomModule
|
176
167
|
def self.go contract
|
177
|
-
# Your test code here
|
168
|
+
# Your test code here
|
178
169
|
# the contract object is the full definition created
|
179
170
|
end
|
180
171
|
|
@@ -187,18 +178,20 @@ end
|
|
187
178
|
config.with_module(CustomModule)
|
188
179
|
```
|
189
180
|
|
190
|
-
|
181
|
+
## Reporting
|
182
|
+
|
191
183
|
Right now the default reporting mechanism prints out to
|
192
184
|
the console all the issues which were found. You can
|
193
185
|
create your own reporting class (so long as it responds
|
194
186
|
to the same methods) or just extend the current one and
|
195
187
|
override the print method. Then set the report
|
196
188
|
tool in the config:
|
189
|
+
|
197
190
|
```ruby
|
198
191
|
config.with_reporter(new_reporter)
|
199
192
|
```
|
200
193
|
|
201
|
-
|
194
|
+
## Development
|
202
195
|
|
203
196
|
After checking out the repo, run `bin/setup` to install
|
204
197
|
dependencies. Then, run `rake spec` to run the tests.
|
@@ -210,11 +203,22 @@ run `bundle exec rake install`.
|
|
210
203
|
|
211
204
|
## Contributing
|
212
205
|
|
213
|
-
Bug reports and pull requests are welcome on GitHub
|
214
|
-
|
206
|
+
Bug reports and pull requests are welcome on [GitHub repo](https://github.com/araneforseti/api-tester).
|
207
|
+
|
208
|
+
## Future Features Under Development
|
215
209
|
|
210
|
+
Check out our [Project Board](https://github.com/araneforseti/api-tester/projects/1) to see progress and where we are headed!
|
211
|
+
Feel free to leave feedback through Github's issue tracker
|
212
|
+
|
213
|
+
- Other Param Testing
|
214
|
+
- Path params
|
215
|
+
- Query
|
216
|
+
- Headers
|
217
|
+
- Documentation
|
218
|
+
- Generate Swagger-compliant documentation
|
219
|
+
- Generate definitions from Swagger documentation
|
216
220
|
|
217
|
-
|
221
|
+
## License
|
218
222
|
|
219
223
|
The gem is available as open source under the terms
|
220
224
|
of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
6
|
+
t.options = ['--display-cop-names']
|
7
|
+
end
|
3
8
|
|
4
9
|
RSpec::Core::RakeTask.new(:spec)
|
5
10
|
|
6
|
-
task :default => :spec
|
11
|
+
task :default => [:rubocop, :spec]
|