mockserver-client 1.0.8.pre → 5.3.0

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 (123) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -1
  3. data/Gemfile.lock +79 -0
  4. data/README.md +89 -229
  5. data/Rakefile +8 -8
  6. data/docs/Body.md +7 -0
  7. data/docs/BodyWithContentType.md +7 -0
  8. data/docs/ConnectionOptions.md +12 -0
  9. data/docs/ControlApi.md +269 -0
  10. data/docs/Delay.md +9 -0
  11. data/docs/Expectation.md +7 -0
  12. data/docs/ExpectationApi.md +51 -0
  13. data/docs/Expectations.md +7 -0
  14. data/docs/HttpClassCallback.md +8 -0
  15. data/docs/HttpError.md +10 -0
  16. data/docs/HttpForward.md +11 -0
  17. data/docs/HttpObjectCallback.md +8 -0
  18. data/docs/HttpOverrideForwardedRequest.md +9 -0
  19. data/docs/HttpRequest.md +15 -0
  20. data/docs/HttpResponse.md +14 -0
  21. data/docs/HttpTemplate.md +10 -0
  22. data/docs/KeyToMultiValue.md +7 -0
  23. data/docs/KeyToValue.md +7 -0
  24. data/docs/Ports.md +8 -0
  25. data/docs/TimeToLive.md +10 -0
  26. data/docs/Times.md +9 -0
  27. data/docs/Verification.md +9 -0
  28. data/docs/VerificationSequence.md +8 -0
  29. data/docs/VerificationTimes.md +9 -0
  30. data/docs/VerifyApi.md +94 -0
  31. data/lib/mockserver-client.rb +62 -15
  32. data/lib/mockserver-client/api/control_api.rb +316 -0
  33. data/lib/mockserver-client/api/expectation_api.rb +73 -0
  34. data/lib/mockserver-client/api/verify_api.rb +127 -0
  35. data/lib/mockserver-client/api_client.rb +388 -0
  36. data/lib/mockserver-client/api_error.rb +38 -0
  37. data/lib/mockserver-client/configuration.rb +202 -0
  38. data/lib/mockserver-client/models/body.rb +174 -0
  39. data/lib/mockserver-client/models/body_with_content_type.rb +174 -0
  40. data/lib/mockserver-client/models/connection_options.rb +219 -0
  41. data/lib/mockserver-client/models/delay.rb +192 -0
  42. data/lib/mockserver-client/models/expectation.rb +174 -0
  43. data/lib/mockserver-client/models/expectations.rb +174 -0
  44. data/lib/mockserver-client/models/http_class_callback.rb +183 -0
  45. data/lib/mockserver-client/models/http_error.rb +201 -0
  46. data/lib/mockserver-client/models/http_forward.rb +244 -0
  47. data/lib/mockserver-client/models/http_object_callback.rb +183 -0
  48. data/lib/mockserver-client/models/http_override_forwarded_request.rb +192 -0
  49. data/lib/mockserver-client/models/http_request.rb +246 -0
  50. data/lib/mockserver-client/models/http_response.rb +237 -0
  51. data/lib/mockserver-client/models/http_template.rb +235 -0
  52. data/lib/mockserver-client/models/key_to_multi_value.rb +174 -0
  53. data/lib/mockserver-client/models/key_to_value.rb +174 -0
  54. data/lib/mockserver-client/models/ports.rb +185 -0
  55. data/lib/mockserver-client/models/time_to_live.rb +235 -0
  56. data/lib/mockserver-client/models/times.rb +192 -0
  57. data/lib/mockserver-client/models/verification.rb +192 -0
  58. data/lib/mockserver-client/models/verification_sequence.rb +185 -0
  59. data/lib/mockserver-client/models/verification_times.rb +192 -0
  60. data/lib/mockserver-client/version.rb +15 -0
  61. data/mockserver-client.gemspec +44 -36
  62. data/spec/api/control_api_spec.rb +102 -0
  63. data/spec/api/expectation_api_spec.rb +46 -0
  64. data/spec/api/verify_api_spec.rb +57 -0
  65. data/spec/api_client_spec.rb +226 -0
  66. data/spec/configuration_spec.rb +42 -0
  67. data/spec/models/body_spec.rb +35 -0
  68. data/spec/models/body_with_content_type_spec.rb +35 -0
  69. data/spec/models/connection_options_spec.rb +65 -0
  70. data/spec/models/delay_spec.rb +47 -0
  71. data/spec/models/expectation_spec.rb +35 -0
  72. data/spec/models/expectations_spec.rb +35 -0
  73. data/spec/models/http_class_callback_spec.rb +41 -0
  74. data/spec/models/http_error_spec.rb +53 -0
  75. data/spec/models/http_forward_spec.rb +63 -0
  76. data/spec/models/http_object_callback_spec.rb +41 -0
  77. data/spec/models/http_override_forwarded_request_spec.rb +47 -0
  78. data/spec/models/http_request_spec.rb +83 -0
  79. data/spec/models/http_response_spec.rb +77 -0
  80. data/spec/models/http_template_spec.rb +57 -0
  81. data/spec/models/key_to_multi_value_spec.rb +35 -0
  82. data/spec/models/key_to_value_spec.rb +35 -0
  83. data/spec/models/ports_spec.rb +41 -0
  84. data/spec/models/time_to_live_spec.rb +57 -0
  85. data/spec/models/times_spec.rb +47 -0
  86. data/spec/models/verification_sequence_spec.rb +41 -0
  87. data/spec/models/verification_spec.rb +47 -0
  88. data/spec/models/verification_times_spec.rb +47 -0
  89. data/spec/spec_helper.rb +103 -53
  90. metadata +225 -158
  91. data/.gitignore +0 -21
  92. data/.rubocop.yml +0 -7
  93. data/bin/mockserver +0 -9
  94. data/lib/cli.rb +0 -146
  95. data/lib/mockserver/abstract_client.rb +0 -111
  96. data/lib/mockserver/mock_server_client.rb +0 -46
  97. data/lib/mockserver/model/array_of.rb +0 -85
  98. data/lib/mockserver/model/body.rb +0 -56
  99. data/lib/mockserver/model/cookie.rb +0 -36
  100. data/lib/mockserver/model/delay.rb +0 -34
  101. data/lib/mockserver/model/enum.rb +0 -47
  102. data/lib/mockserver/model/expectation.rb +0 -139
  103. data/lib/mockserver/model/forward.rb +0 -41
  104. data/lib/mockserver/model/header.rb +0 -43
  105. data/lib/mockserver/model/parameter.rb +0 -43
  106. data/lib/mockserver/model/request.rb +0 -81
  107. data/lib/mockserver/model/response.rb +0 -45
  108. data/lib/mockserver/model/times.rb +0 -61
  109. data/lib/mockserver/proxy_client.rb +0 -9
  110. data/lib/mockserver/utility_methods.rb +0 -59
  111. data/lib/mockserver/version.rb +0 -5
  112. data/pom.xml +0 -118
  113. data/spec/fixtures/forward_mockserver.json +0 -7
  114. data/spec/fixtures/incorrect_login_response.json +0 -20
  115. data/spec/fixtures/post_login_request.json +0 -22
  116. data/spec/fixtures/register_expectation.json +0 -50
  117. data/spec/fixtures/retrieved_request.json +0 -22
  118. data/spec/fixtures/search_request.json +0 -6
  119. data/spec/fixtures/times_once.json +0 -6
  120. data/spec/integration/mock_client_integration_spec.rb +0 -82
  121. data/spec/mockserver/builder_spec.rb +0 -90
  122. data/spec/mockserver/mock_client_spec.rb +0 -80
  123. data/spec/mockserver/proxy_client_spec.rb +0 -38
@@ -1,45 +0,0 @@
1
- # encoding: UTF-8
2
- require_relative './body'
3
- require_relative './delay'
4
- require_relative './header'
5
- require_relative './cookie'
6
- require 'base64'
7
-
8
- #
9
- # A class to model a response in an expectation.
10
- # @author:: Nayyara Samuel (mailto: nayyara.samuel@opower.com)
11
- #
12
- module MockServer::Model
13
- # Model for a mock response
14
- class Response < Hashie::Dash
15
- include Hashie::Extensions::MethodAccess
16
- include Hashie::Extensions::IgnoreUndeclared
17
- include Hashie::Extensions::Coercion
18
-
19
- property :status_code, default: 200
20
- property :cookies, default: Cookies.new([])
21
- property :headers, default: Headers.new([])
22
- property :delay
23
- property :body
24
-
25
- coerce_key :cookies, Cookies
26
- coerce_key :headers, Headers
27
- coerce_key :delay, Delay
28
- coerce_key :body, String
29
- end
30
-
31
- # DSL Methods for a response
32
- module DSL
33
- def response(&_)
34
- obj = Response.new
35
- yield obj if block_given?
36
- obj
37
- end
38
-
39
- def decode(string)
40
- Base64.decode64(string)
41
- end
42
-
43
- alias_method :http_response, :response
44
- end
45
- end
@@ -1,61 +0,0 @@
1
- # encoding: UTF-8
2
- require 'hashie'
3
- require_relative './enum'
4
-
5
- #
6
- # A class to model the number of times an expectation should be respected.
7
- # @author:: Nayyara Samuel (mailto: nayyara.samuel@opower.com)
8
- #
9
- module MockServer::Model
10
- # Enum for boolean values since Ruby does not have this by default
11
- class Boolean < Enum
12
- def allowed_values
13
- [true, false]
14
- end
15
-
16
- def !
17
- !@value
18
- end
19
-
20
- def initialize(supplied_value)
21
- @value = pre_process_value(supplied_value)
22
- end
23
- end
24
-
25
- # Model for times class
26
- class Times < Hashie::Dash
27
- include Hashie::Extensions::MethodAccess
28
- include Hashie::Extensions::IgnoreUndeclared
29
- include Hashie::Extensions::Coercion
30
-
31
- property :remaining_times, default: 0
32
- property :unlimited, default: false
33
-
34
- coerce_key :unlimited, Boolean
35
- end
36
-
37
- # DSL methods related to times
38
- module DSL
39
- def unlimited
40
- Times.new(unlimited: true)
41
- end
42
-
43
- def once
44
- Times.new(remaining_times: 1)
45
- end
46
-
47
- def exactly(num)
48
- Times.new(remaining_times: num)
49
- end
50
-
51
- def at_least(num)
52
- Times.new(remaining_times: num, unlimited: true)
53
- end
54
-
55
- def times(&_)
56
- obj = once
57
- yield obj if block_given?
58
- obj
59
- end
60
- end
61
- end
@@ -1,9 +0,0 @@
1
- # encoding: UTF-8
2
- require_relative './abstract_client'
3
-
4
- #
5
- # The client used to interact with the proxy server.
6
- # @author:: Nayyara Samuel (mailto: nayyara.samuel@opower.com)
7
- #
8
- class MockServer::ProxyClient < MockServer::AbstractClient
9
- end
@@ -1,59 +0,0 @@
1
- # encoding: UTF-8
2
- require 'active_support/inflector'
3
- require 'json'
4
-
5
- #
6
- # A module that has common utility methods used by this project
7
- # @author:: Nayyara Samuel (mailto: nayyara.samuel@opower.com)
8
- #
9
- module MockServer::UtilityMethods
10
- # Does the following filter/transform operations on a hash
11
- # - exclude null or empty valued keys from the hash
12
- # - camelize the keys of the hash
13
- # @param obj [Object] an object which will be used to create the hash. Must support :to_hash method
14
- # @return [Hash] the transformed hash
15
- # rubocop:disable Style/MethodLength
16
- # rubocop:disable Style/CyclomaticComplexity
17
- def camelized_hash(obj)
18
- obj = obj && obj.respond_to?(:to_hash) ? obj.to_hash : obj
19
-
20
- if obj.is_a?(Hash)
21
- obj.each_with_object({}) do |(k, v), acc|
22
- is_empty = v.nil? || (v.respond_to?(:empty?) ? v.empty? : false)
23
- acc[camelize(k)] = camelized_hash(v) unless is_empty
24
- end
25
- elsif obj.respond_to?(:map)
26
- obj.map { |element| camelized_hash(element) }
27
- else
28
- obj
29
- end
30
- end
31
-
32
- # Converts keys to symbols
33
- # @param hash [Hash] a hash
34
- # @return [Hash] a copy of the hash where keys are symbols
35
- def symbolize_keys(hash)
36
- if hash.is_a?(Hash)
37
- Hash[hash.map { |k, v| [k.to_s.underscore.to_sym, symbolize_keys(v)] }]
38
- elsif hash.respond_to?(:map)
39
- hash.map { |obj| symbolize_keys(obj) }
40
- else
41
- hash
42
- end
43
- end
44
-
45
- # @param str [Object] an object to camelize the string representation of
46
- # @return [String] the string converted to camelcase with first letter in lower case
47
- def camelize(str)
48
- str.to_s.camelize(:lower)
49
- end
50
-
51
- # Parse string response into JSON
52
- # @param response [Response] from RestClient response
53
- # @return [Hash] the parsed response or the object unmodified if parsing is not possible
54
- def parse_string_to_json(response)
55
- JSON.parse(response)
56
- rescue JSON::ParserError
57
- response
58
- end
59
- end
@@ -1,5 +0,0 @@
1
- # encoding: UTF-8
2
- # Version for this gem
3
- module MockServer
4
- VERSION = '1.0.8.pre'
5
- end
data/pom.xml DELETED
@@ -1,118 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
- <parent>
4
- <groupId>org.mock-server</groupId>
5
- <artifactId>mockserver</artifactId>
6
- <version>3.10.2-SNAPSHOT</version>
7
- </parent>
8
- <modelVersion>4.0.0</modelVersion>
9
-
10
- <artifactId>mockserver-client-ruby</artifactId>
11
- <name>MockServer Ruby Client</name>
12
- <description>A ruby client for the MockServer</description>
13
- <url>http://www.mock-server.com</url>
14
-
15
- <properties>
16
- <skipRubyRelease>true</skipRubyRelease>
17
- <skipRubyBuild>false</skipRubyBuild>
18
- </properties>
19
-
20
- <build>
21
- <plugins>
22
- <!-- run mock server for ruby client tests -->
23
- <plugin>
24
- <groupId>${project.groupId}</groupId>
25
- <artifactId>mockserver-maven-plugin</artifactId>
26
- <version>${project.version}</version>
27
- <configuration>
28
- <logLevel>WARN</logLevel>
29
- <serverPort>1080</serverPort>
30
- <proxyPort>1090</proxyPort>
31
- </configuration>
32
- <executions>
33
- <execution>
34
- <id>pre-test</id>
35
- <phase>generate-test-sources</phase>
36
- <goals>
37
- <goal>start</goal>
38
- </goals>
39
- </execution>
40
- <execution>
41
- <id>post-test</id>
42
- <phase>verify</phase>
43
- <goals>
44
- <goal>stop</goal>
45
- </goals>
46
- </execution>
47
- </executions>
48
- </plugin>
49
- <!-- run ruby bundle build and install -->
50
- <plugin>
51
- <groupId>org.codehaus.mojo</groupId>
52
- <artifactId>exec-maven-plugin</artifactId>
53
- <version>1.4.0</version>
54
- <executions>
55
- <execution>
56
- <id>bundle_install</id>
57
- <phase>prepare-package</phase>
58
- <goals>
59
- <goal>exec</goal>
60
- </goals>
61
- <configuration>
62
- <skip>${skipRubyBuild}</skip>
63
- <executable>bundle</executable>
64
- <arguments>
65
- <argument>install</argument>
66
- <argument>--path</argument>
67
- <argument>vendor/bundle</argument>
68
- </arguments>
69
- <environmentVariables>
70
- <BUNDLE_GEMFILE>${basedir}/Gemfile</BUNDLE_GEMFILE>
71
- </environmentVariables>
72
- </configuration>
73
- </execution>
74
- <execution>
75
- <id>ruby_make</id>
76
- <phase>prepare-package</phase>
77
- <goals>
78
- <goal>exec</goal>
79
- </goals>
80
- <configuration>
81
- <skip>${skipRubyBuild}</skip>
82
- <executable>bundle</executable>
83
- <arguments>
84
- <argument>exec</argument>
85
- <argument>rake</argument>
86
- <argument>build</argument>
87
- <argument>spec</argument>
88
- </arguments>
89
- <environmentVariables>
90
- <BUNDLE_GEMFILE>${basedir}/Gemfile</BUNDLE_GEMFILE>
91
- </environmentVariables>
92
- </configuration>
93
- </execution>
94
- <execution>
95
- <id>ruby_release</id>
96
- <phase>deploy</phase>
97
- <goals>
98
- <goal>exec</goal>
99
- </goals>
100
- <configuration>
101
- <skip>${skipRubyRelease}</skip>
102
- <executable>bundle</executable>
103
- <arguments>
104
- <argument>exec</argument>
105
- <argument>rake</argument>
106
- <argument>release</argument>
107
- </arguments>
108
- <environmentVariables>
109
- <BUNDLE_GEMFILE>${basedir}/Gemfile</BUNDLE_GEMFILE>
110
- </environmentVariables>
111
- </configuration>
112
- </execution>
113
- </executions>
114
- </plugin>
115
- </plugins>
116
- </build>
117
-
118
- </project>
@@ -1,7 +0,0 @@
1
- {
2
- "httpForward": {
3
- "host": "www.mock-server.com",
4
- "port": 80,
5
- "scheme": "HTTP"
6
- }
7
- }
@@ -1,20 +0,0 @@
1
- {
2
- "httpResponse": {
3
- "statusCode": 401,
4
- "headers": [
5
- {
6
- "name": "Content-Type",
7
- "values": ["application/json; charset=utf-8"]
8
- },
9
- {
10
- "name": "Cache-Control",
11
- "values": ["public, max-age=86400"]
12
- }
13
- ],
14
- "body": "incorrect username and password combination",
15
- "delay": {
16
- "timeUnit": "SECONDS",
17
- "value": 1
18
- }
19
- }
20
- }
@@ -1,22 +0,0 @@
1
- {
2
- "httpRequest": {
3
- "method": "POST",
4
- "path": "/login",
5
- "queryStringParameters": [
6
- {
7
- "name": "returnUrl",
8
- "values": ["/account"]
9
- }
10
- ],
11
- "cookies": [
12
- {
13
- "name": "sessionId",
14
- "value": "2By8LOhBmaW5nZXJwcmludCIlMDAzMW"
15
- }
16
- ],
17
- "body": {
18
- "type": "STRING",
19
- "value": "{username:'foo', password:'bar'}"
20
- }
21
- }
22
- }
@@ -1,50 +0,0 @@
1
- {
2
- "httpRequest": {
3
- "method": "POST",
4
- "path": "/login",
5
- "queryStringParameters": [
6
- {
7
- "values": [
8
- "/account"
9
- ],
10
- "name": "returnUrl"
11
- }
12
- ],
13
- "cookies": [
14
- {
15
- "name": "sessionId",
16
- "value": "2By8LOhBmaW5nZXJwcmludCIlMDAzMW"
17
- }
18
- ],
19
- "body": {
20
- "type": "STRING",
21
- "value": "{\"username\":\"foo\",\"password\":\"bar\"}"
22
- }
23
- },
24
- "httpResponse": {
25
- "statusCode": 401,
26
- "headers": [
27
- {
28
- "values": [
29
- "application/json; charset=utf-8"
30
- ],
31
- "name": "Content-Type"
32
- },
33
- {
34
- "values": [
35
- "public, max-age=86400"
36
- ],
37
- "name": "Cache-Control"
38
- }
39
- ],
40
- "body": "{\"message\":\"incorrect username and password combination\"}",
41
- "delay": {
42
- "timeUnit": "SECONDS",
43
- "value": 1
44
- }
45
- },
46
- "times": {
47
- "remainingTimes": 2,
48
- "unlimited": "false"
49
- }
50
- }
@@ -1,22 +0,0 @@
1
- {
2
- "method": "POST",
3
- "path": "/login",
4
- "queryStringParameters": [
5
- {
6
- "values": [
7
- "/account"
8
- ],
9
- "name": "returnUrl"
10
- }
11
- ],
12
- "cookies": [
13
- {
14
- "value": "2By8LOhBmaW5nZXJwcmludCIlMDAzMW",
15
- "name": "sessionId"
16
- }
17
- ],
18
- "body": {
19
- "type": "STRING",
20
- "value": "{\"username\":\"foo\",\"password\":\"bar\"}"
21
- }
22
- }
@@ -1,6 +0,0 @@
1
- {
2
- "httpRequest": {
3
- "method": "POST",
4
- "path": "/login"
5
- }
6
- }
@@ -1,6 +0,0 @@
1
- {
2
- "times": {
3
- "remainingTimes": 1,
4
- "unlimited": "false"
5
- }
6
- }