rutrack 0.0.11.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,76 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://testcloud.myjetbrains.com/youtrack/rest/user/login
6
+ body:
7
+ encoding: UTF-8
8
+ string: login=testuser&password=testuser
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - nginx
17
+ Date:
18
+ - Fri, 07 Feb 2014 22:39:55 GMT
19
+ Content-Type:
20
+ - application/xml; charset=UTF-8
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ Vary:
26
+ - Accept-Encoding
27
+ Set-Cookie:
28
+ - JSESSIONID=114e57my63svq68gcd6kn2821;Path=/youtrack;Secure
29
+ - jetbrains.charisma.main.security.PRINCIPAL=YWU1ZGViODIyZTBkNzE5OTI5MDA0NzFhNzE5OWQwZDk1YjhlN2M5ZDA1YzQwYTgyNDVhMjgxZmQyYzFkNjY4NDp0ZXN0dXNlcg;Path=/youtrack;Expires=Sat,
30
+ 07-Feb-2015 22:39:55 GMT
31
+ Expires:
32
+ - Thu, 01 Jan 1970 00:00:00 GMT
33
+ Cache-Control:
34
+ - no-cache, no-store, no-transform, must-revalidate
35
+ body:
36
+ encoding: UTF-8
37
+ string: <login>ok</login>
38
+ http_version:
39
+ recorded_at: Fri, 07 Feb 2014 22:41:41 GMT
40
+ - request:
41
+ method: get
42
+ uri: https://testcloud.myjetbrains.com/youtrack/rest/user/testuser/filter
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ''
46
+ headers:
47
+ Cookie:
48
+ - JSESSIONID=114e57my63svq68gcd6kn2821;Path=/youtrack;Secure, jetbrains.charisma.main.security.PRINCIPAL=YWU1ZGViODIyZTBkNzE5OTI5MDA0NzFhNzE5OWQwZDk1YjhlN2M5ZDA1YzQwYTgyNDVhMjgxZmQyYzFkNjY4NDp0ZXN0dXNlcg;Path=/youtrack;Expires=Sat,
49
+ 07-Feb-2015 22:39:55 GMT
50
+ response:
51
+ status:
52
+ code: 200
53
+ message: OK
54
+ headers:
55
+ Server:
56
+ - nginx
57
+ Date:
58
+ - Fri, 07 Feb 2014 22:41:16 GMT
59
+ Content-Type:
60
+ - application/xml; charset=UTF-8
61
+ Content-Length:
62
+ - '218'
63
+ Connection:
64
+ - keep-alive
65
+ Vary:
66
+ - Accept-Encoding
67
+ Cache-Control:
68
+ - no-cache, no-store, no-transform, must-revalidate
69
+ body:
70
+ encoding: UTF-8
71
+ string: '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><queries><query
72
+ name="Assigned to me" query="for: me"/><query name="Commented by me" query="commenter:
73
+ me"/><query name="Reported by me" query="by: me"/></queries>'
74
+ http_version:
75
+ recorded_at: Fri, 07 Feb 2014 22:43:02 GMT
76
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,40 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+
8
+ require "webmock/rspec"
9
+ require "youtrack"
10
+ require "vcr"
11
+
12
+ VCR.configure do |c|
13
+ c.cassette_library_dir = "spec/cassettes"
14
+ c.hook_into :webmock
15
+ c.configure_rspec_metadata!
16
+ end
17
+
18
+ RSpec.configure do |config|
19
+ config.treat_symbols_as_metadata_keys_with_true_values = true
20
+ config.run_all_when_everything_filtered = true
21
+ config.filter_run :focus
22
+
23
+ config.treat_symbols_as_metadata_keys_with_true_values = true
24
+ config.extend VCR::RSpec::Macros
25
+
26
+ # Run specs in random order to surface order dependencies. If you find an
27
+ # order dependency and want to debug it, you can fix the order by providing
28
+ # the seed, which is printed after each run.
29
+ # --seed 1234
30
+ config.order = 'random'
31
+ end
32
+
33
+ def build_client(proto="http", user, pass)
34
+ Youtrack::Client.new do |c|
35
+ c.url = "#{proto}://testcloud.myjetbrains.com/youtrack"
36
+ c.login = user
37
+ c.password = pass
38
+ end
39
+ end
40
+
@@ -0,0 +1,92 @@
1
+ require "spec_helper"
2
+
3
+ describe Youtrack::Client do
4
+
5
+ describe "attributes" do
6
+
7
+ # Mutators
8
+ it { should respond_to(:url=) }
9
+ it { should respond_to(:login=) }
10
+ it { should respond_to(:password=) }
11
+ it { should respond_to(:cookies=) }
12
+ it { should respond_to(:connection=) }
13
+ it { should respond_to(:admin=) }
14
+
15
+ # Accessors
16
+ it { should respond_to(:admin?) }
17
+ it { should respond_to(:connected?) }
18
+ it { should respond_to(:credentials_hash) }
19
+ it { should respond_to(:endpoint) }
20
+ end
21
+
22
+ describe "resources" do
23
+ it { should respond_to(:users) }
24
+ it { should respond_to(:projects) }
25
+ it { should respond_to(:issues) }
26
+ end
27
+
28
+ describe "connecting" do
29
+
30
+ context "success" do
31
+ let(:client) { build_client("https", "testuser", "testuser") }
32
+ use_vcr_cassette "client/connect"
33
+
34
+ it "should connect to a youtrack endpoint when having valid credentials" do
35
+ client.connect!
36
+
37
+ # STATUS
38
+ expect(client.connected?).to eq(true)
39
+ expect(client.connection.code).to eq(200)
40
+ expect(client.connection.message).to eq("OK")
41
+
42
+ # MESSAGE
43
+ entity_body = client.connection.parsed_response
44
+ expect(entity_body["error"]).to eq(nil)
45
+ expect(entity_body["login"]).to eq("ok")
46
+
47
+ # AUTH COOKIE
48
+ expect(client.connection.response["set-cookie"]).to match(%r{jetbrains.charisma.main.security})
49
+ end
50
+
51
+ end
52
+
53
+ context "credentials failure" do
54
+ let(:client) { build_client("https", "invalid_user", "invalid_pass") }
55
+ use_vcr_cassette "client/connect_credentials_error"
56
+
57
+ it "should not connect to a youtrack endpoint when credentials are invalid" do
58
+ client.connect!
59
+
60
+ # STATUS
61
+ expect(client.connected?).to eq(false)
62
+ expect(client.connection.code).to eq(403)
63
+ expect(client.connection.message).to eq("Forbidden")
64
+
65
+ # MESSAGE
66
+ entity_body = client.connection.parsed_response
67
+ expect(entity_body["login"]).to eq(nil)
68
+ expect(entity_body["error"]).to eq("Incorrect login or password.")
69
+
70
+ # AUTH COOKIE
71
+ expect(client.connection.response["set-cookie"]).to_not match(%r{jetbrains.charisma.main.security})
72
+ end
73
+ end
74
+
75
+ context "url endpoint failure" do
76
+ let(:client) { build_client("https", "testuser", "testuser") }
77
+ use_vcr_cassette "client/connect_url_error"
78
+
79
+ it "should not connect to a youtrack endpoint when the url is invalid" do
80
+ client.url = "https://testcloud.myjetbrains.com/youtracks"
81
+ client.connect!
82
+
83
+ # STATUS
84
+ expect(client.connected?).to eq(false)
85
+ expect(client.connection.code).to eq(404)
86
+ expect(client.connection.message).to eq("Not Found")
87
+
88
+ end
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,83 @@
1
+ require "spec_helper"
2
+
3
+ describe Youtrack::User do
4
+ describe "api methods" do
5
+ use_vcr_cassette "users/init", record: :new_episodes
6
+
7
+ let(:users) do
8
+ client = build_client("https", "testuser", "testuser")
9
+ client.connect!
10
+ client.users
11
+ end
12
+
13
+ context "#current" do
14
+ use_vcr_cassette "users/current", record: :new_episodes
15
+
16
+ it "should take no arguments" do
17
+ expect(users.method(:current).arity).to eq(0)
18
+ end
19
+
20
+ it "should return info about the currently authenticated user" do
21
+ entity_body = users.current
22
+
23
+ # STATUS
24
+ expect(users.response.code).to eq(200)
25
+
26
+ # BODY
27
+ expect(entity_body["user"]).to be_kind_of(Hash)
28
+ user_hash = entity_body["user"]
29
+
30
+ expect(user_hash.keys).to include("login")
31
+ expect(user_hash.keys).to include("email")
32
+ expect(user_hash.keys).to include("fullName")
33
+ end
34
+
35
+ end
36
+
37
+ context "#get_by_login" do
38
+ use_vcr_cassette "users/get_by_login", record: :new_episodes
39
+
40
+ it "should take one argument the user's login name" do
41
+ users.method(:get_by_login).arity.should eq(1)
42
+ end
43
+
44
+ it "should return info about a searched for user" do
45
+ entity_body = users.get_by_login("testuser")
46
+
47
+ # STATUS
48
+ expect(users.response.code).to eq(200)
49
+
50
+ # BODY
51
+ user_hash = entity_body["user"]
52
+ expect(user_hash).to be_kind_of(Hash)
53
+ expect(user_hash["login"]).to_not eq(nil)
54
+ expect(user_hash["email"]).to_not eq(nil)
55
+ expect(user_hash["fullName"]).to_not eq(nil)
56
+
57
+ end
58
+ end
59
+
60
+ context "#get_saved_searches_for" do
61
+ use_vcr_cassette "users/get_saved_searches_for", record: :new_episodes
62
+
63
+ it "should take one argument the user's login name" do
64
+ users.method(:get_saved_searches_for).arity.should eq(1)
65
+ end
66
+
67
+ it "should return a list of the user's saved searches with name/query keys" do
68
+ entity_body = users.get_saved_searches_for("testuser")
69
+
70
+ # STATUS
71
+ expect(users.response.code).to eq(200)
72
+
73
+ # BODY
74
+ query_ary = entity_body["queries"]["query"].first
75
+ expect(query_ary).to be_kind_of(Hash)
76
+ expect(query_ary["name"]).to_not eq(nil)
77
+ expect(query_ary["query"]).to_not eq(nil)
78
+ end
79
+ end
80
+
81
+ end
82
+
83
+ end
data/youtrack.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'youtrack/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+
8
+ # META
9
+ spec.name = "rutrack"
10
+ spec.version = Youtrack::VERSION
11
+ spec.authors = ["John Faucett"]
12
+ spec.email = ["jwaterfaucett@gmail.com"]
13
+ spec.description = %q{JetBrains youTrack Rest API Client in Ruby}
14
+ spec.summary = %q{A Ruby REST API Client for JetBrains youTrack software}
15
+ spec.homepage = "http://jwaterfaucett.github.io/youtrack/"
16
+ spec.license = "MIT"
17
+
18
+ # FILES
19
+ spec.files = `git ls-files`.split($/).grep(%r{^(?!binstubs|examples)})
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ # HARD DEPENDENCY
25
+ spec.add_dependency "httparty"
26
+ spec.add_dependency "multipart-post"
27
+
28
+ # DEVELOPMENT
29
+ spec.add_development_dependency "bundler", "~> 1.3"
30
+ spec.add_development_dependency "rake"
31
+ spec.add_development_dependency "cucumber", "~> 1.3.10"
32
+ spec.add_development_dependency "rspec", "~> 2.14.1"
33
+ spec.add_development_dependency "webmock", "~> 1.17.1"
34
+ spec.add_development_dependency "vcr", "~> 2.8.0"
35
+ end
metadata ADDED
@@ -0,0 +1,201 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rutrack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.11.1
5
+ platform: ruby
6
+ authors:
7
+ - John Faucett
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multipart-post
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: cucumber
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.10
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.10
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.14.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.14.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.17.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.17.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 2.8.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 2.8.0
125
+ description: JetBrains youTrack Rest API Client in Ruby
126
+ email:
127
+ - jwaterfaucett@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".envrc"
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".ruby-gemset"
136
+ - ".ruby-version"
137
+ - ".travis.yml"
138
+ - Gemfile
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - features/support/env.rb
143
+ - features/support/hooks.rb
144
+ - features/support/vcr.rb
145
+ - features/support/world.rb
146
+ - lib/youtrack.rb
147
+ - lib/youtrack/client.rb
148
+ - lib/youtrack/resources/base.rb
149
+ - lib/youtrack/resources/issue.rb
150
+ - lib/youtrack/resources/project.rb
151
+ - lib/youtrack/resources/tag.rb
152
+ - lib/youtrack/resources/user.rb
153
+ - lib/youtrack/version.rb
154
+ - spec/cassettes/client/connect.yml
155
+ - spec/cassettes/client/connect_credentials_error.yml
156
+ - spec/cassettes/client/connect_url_error.yml
157
+ - spec/cassettes/users/current.yml
158
+ - spec/cassettes/users/get_by_login.yml
159
+ - spec/cassettes/users/get_saved_searches_for.yml
160
+ - spec/spec_helper.rb
161
+ - spec/youtrack/client_spec.rb
162
+ - spec/youtrack/resources/user_spec.rb
163
+ - youtrack.gemspec
164
+ homepage: http://jwaterfaucett.github.io/youtrack/
165
+ licenses:
166
+ - MIT
167
+ metadata: {}
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ requirements: []
183
+ rubyforge_project:
184
+ rubygems_version: 2.5.1
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: A Ruby REST API Client for JetBrains youTrack software
188
+ test_files:
189
+ - features/support/env.rb
190
+ - features/support/hooks.rb
191
+ - features/support/vcr.rb
192
+ - features/support/world.rb
193
+ - spec/cassettes/client/connect.yml
194
+ - spec/cassettes/client/connect_credentials_error.yml
195
+ - spec/cassettes/client/connect_url_error.yml
196
+ - spec/cassettes/users/current.yml
197
+ - spec/cassettes/users/get_by_login.yml
198
+ - spec/cassettes/users/get_saved_searches_for.yml
199
+ - spec/spec_helper.rb
200
+ - spec/youtrack/client_spec.rb
201
+ - spec/youtrack/resources/user_spec.rb