unienv_api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,243 @@
1
+ =begin
2
+ #UniEnv Core API
3
+
4
+ #Документация по API UniEnv
5
+
6
+ OpenAPI spec version: v1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.24-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe SwaggerClient::ApiClient do
16
+ context 'initialization' do
17
+ context 'URL stuff' do
18
+ context 'host' do
19
+ it 'removes http from host' do
20
+ SwaggerClient.configure { |c| c.host = 'http://example.com' }
21
+ expect(SwaggerClient::Configuration.default.host).to eq('example.com')
22
+ end
23
+
24
+ it 'removes https from host' do
25
+ SwaggerClient.configure { |c| c.host = 'https://wookiee.com' }
26
+ expect(SwaggerClient::ApiClient.default.config.host).to eq('wookiee.com')
27
+ end
28
+
29
+ it 'removes trailing path from host' do
30
+ SwaggerClient.configure { |c| c.host = 'hobo.com/v4' }
31
+ expect(SwaggerClient::Configuration.default.host).to eq('hobo.com')
32
+ end
33
+ end
34
+
35
+ context 'base_path' do
36
+ it "prepends a slash to base_path" do
37
+ SwaggerClient.configure { |c| c.base_path = 'v4/dog' }
38
+ expect(SwaggerClient::Configuration.default.base_path).to eq('/v4/dog')
39
+ end
40
+
41
+ it "doesn't prepend a slash if one is already there" do
42
+ SwaggerClient.configure { |c| c.base_path = '/v4/dog' }
43
+ expect(SwaggerClient::Configuration.default.base_path).to eq('/v4/dog')
44
+ end
45
+
46
+ it "ends up as a blank string if nil" do
47
+ SwaggerClient.configure { |c| c.base_path = nil }
48
+ expect(SwaggerClient::Configuration.default.base_path).to eq('')
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ describe 'params_encoding in #build_request' do
55
+ let(:config) { SwaggerClient::Configuration.new }
56
+ let(:api_client) { SwaggerClient::ApiClient.new(config) }
57
+
58
+ it 'defaults to nil' do
59
+ expect(SwaggerClient::Configuration.default.params_encoding).to eq(nil)
60
+ expect(config.params_encoding).to eq(nil)
61
+
62
+ request = api_client.build_request(:get, '/test')
63
+ expect(request.options[:params_encoding]).to eq(nil)
64
+ end
65
+
66
+ it 'can be customized' do
67
+ config.params_encoding = :multi
68
+ request = api_client.build_request(:get, '/test')
69
+ expect(request.options[:params_encoding]).to eq(:multi)
70
+ end
71
+ end
72
+
73
+ describe 'timeout in #build_request' do
74
+ let(:config) { SwaggerClient::Configuration.new }
75
+ let(:api_client) { SwaggerClient::ApiClient.new(config) }
76
+
77
+ it 'defaults to 0' do
78
+ expect(SwaggerClient::Configuration.default.timeout).to eq(0)
79
+ expect(config.timeout).to eq(0)
80
+
81
+ request = api_client.build_request(:get, '/test')
82
+ expect(request.options[:timeout]).to eq(0)
83
+ end
84
+
85
+ it 'can be customized' do
86
+ config.timeout = 100
87
+ request = api_client.build_request(:get, '/test')
88
+ expect(request.options[:timeout]).to eq(100)
89
+ end
90
+ end
91
+
92
+ describe '#build_request' do
93
+ let(:config) { SwaggerClient::Configuration.new }
94
+ let(:api_client) { SwaggerClient::ApiClient.new(config) }
95
+
96
+ it 'does not send multipart to request' do
97
+ expect(Typhoeus::Request).to receive(:new).with(anything, hash_not_including(:multipart))
98
+ api_client.build_request(:get, '/test')
99
+ end
100
+
101
+ context 'when the content type is multipart' do
102
+ it 'sends multipart to request' do
103
+ expect(Typhoeus::Request).to receive(:new).with(anything, hash_including(multipart: true))
104
+ api_client.build_request(:get, '/test', {header_params: { 'Content-Type' => 'multipart/form-data'}})
105
+ end
106
+ end
107
+ end
108
+
109
+ describe '#deserialize' do
110
+ it "handles Array<Integer>" do
111
+ api_client = SwaggerClient::ApiClient.new
112
+ headers = { 'Content-Type' => 'application/json' }
113
+ response = double('response', headers: headers, body: '[12, 34]')
114
+ data = api_client.deserialize(response, 'Array<Integer>')
115
+ expect(data).to be_instance_of(Array)
116
+ expect(data).to eq([12, 34])
117
+ end
118
+
119
+ it 'handles Array<Array<Integer>>' do
120
+ api_client = SwaggerClient::ApiClient.new
121
+ headers = { 'Content-Type' => 'application/json' }
122
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
123
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
124
+ expect(data).to be_instance_of(Array)
125
+ expect(data).to eq([[12, 34], [56]])
126
+ end
127
+
128
+ it 'handles Hash<String, String>' do
129
+ api_client = SwaggerClient::ApiClient.new
130
+ headers = { 'Content-Type' => 'application/json' }
131
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
132
+ data = api_client.deserialize(response, 'Hash<String, String>')
133
+ expect(data).to be_instance_of(Hash)
134
+ expect(data).to eq(:message => 'Hello')
135
+ end
136
+ end
137
+
138
+ describe "#object_to_hash" do
139
+ it 'ignores nils and includes empty arrays' do
140
+ # uncomment below to test object_to_hash for model
141
+ # api_client = SwaggerClient::ApiClient.new
142
+ # _model = SwaggerClient::ModelName.new
143
+ # update the model attribute below
144
+ # _model.id = 1
145
+ # update the expected value (hash) below
146
+ # expected = {id: 1, name: '', tags: []}
147
+ # expect(api_client.object_to_hash(_model)).to eq(expected)
148
+ end
149
+ end
150
+
151
+ describe '#build_collection_param' do
152
+ let(:param) { ['aa', 'bb', 'cc'] }
153
+ let(:api_client) { SwaggerClient::ApiClient.new }
154
+
155
+ it 'works for csv' do
156
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
157
+ end
158
+
159
+ it 'works for ssv' do
160
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
161
+ end
162
+
163
+ it 'works for tsv' do
164
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
165
+ end
166
+
167
+ it 'works for pipes' do
168
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
169
+ end
170
+
171
+ it 'works for multi' do
172
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
173
+ end
174
+
175
+ it 'fails for invalid collection format' do
176
+ expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
177
+ end
178
+ end
179
+
180
+ describe '#json_mime?' do
181
+ let(:api_client) { SwaggerClient::ApiClient.new }
182
+
183
+ it 'works' do
184
+ expect(api_client.json_mime?(nil)).to eq false
185
+ expect(api_client.json_mime?('')).to eq false
186
+
187
+ expect(api_client.json_mime?('application/json')).to eq true
188
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
189
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
190
+
191
+ expect(api_client.json_mime?('application/xml')).to eq false
192
+ expect(api_client.json_mime?('text/plain')).to eq false
193
+ expect(api_client.json_mime?('application/jsonp')).to eq false
194
+ end
195
+ end
196
+
197
+ describe '#select_header_accept' do
198
+ let(:api_client) { SwaggerClient::ApiClient.new }
199
+
200
+ it 'works' do
201
+ expect(api_client.select_header_accept(nil)).to be_nil
202
+ expect(api_client.select_header_accept([])).to be_nil
203
+
204
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
205
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
206
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
207
+
208
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
209
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
210
+ end
211
+ end
212
+
213
+ describe '#select_header_content_type' do
214
+ let(:api_client) { SwaggerClient::ApiClient.new }
215
+
216
+ it 'works' do
217
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
218
+ expect(api_client.select_header_content_type([])).to eq('application/json')
219
+
220
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
221
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
222
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
223
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
224
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
225
+ end
226
+ end
227
+
228
+ describe '#sanitize_filename' do
229
+ let(:api_client) { SwaggerClient::ApiClient.new }
230
+
231
+ it 'works' do
232
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
233
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
234
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
235
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
236
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
237
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
238
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
239
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
240
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
241
+ end
242
+ end
243
+ end
@@ -0,0 +1,42 @@
1
+ =begin
2
+ #UniEnv Core API
3
+
4
+ #Документация по API UniEnv
5
+
6
+ OpenAPI spec version: v1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.24-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe SwaggerClient::Configuration do
16
+ let(:config) { SwaggerClient::Configuration.default }
17
+
18
+ before(:each) do
19
+ # uncomment below to setup host and base_path
20
+ # require 'URI'
21
+ # uri = URI.parse("http://uenv-core.kpfu.ru/api/v1.0/")
22
+ # SwaggerClient.configure do |c|
23
+ # c.host = uri.host
24
+ # c.base_path = uri.path
25
+ # end
26
+ end
27
+
28
+ describe '#base_url' do
29
+ it 'should have the default value' do
30
+ # uncomment below to test default value of the base path
31
+ # expect(config.base_url).to eq("http://uenv-core.kpfu.ru/api/v1.0/")
32
+ end
33
+
34
+ it 'should remove trailing slashes' do
35
+ [nil, '', '/', '//'].each do |base_path|
36
+ config.base_path = base_path
37
+ # uncomment below to test trailing slashes
38
+ # expect(config.base_url).to eq("http://uenv-core.kpfu.ru/api/v1.0/")
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,65 @@
1
+ =begin
2
+ #UniEnv Core API
3
+
4
+ #Документация по API UniEnv
5
+
6
+ OpenAPI spec version: v1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.24-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+ require 'date'
16
+
17
+ # Unit tests for SwaggerClient::Group
18
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
19
+ # Please update as you see appropriate
20
+ describe 'Group' do
21
+ before do
22
+ # run before each test
23
+ @instance = SwaggerClient::Group.new
24
+ end
25
+
26
+ after do
27
+ # run after each test
28
+ end
29
+
30
+ describe 'test an instance of Group' do
31
+ it 'should create an instance of Group' do
32
+ expect(@instance).to be_instance_of(SwaggerClient::Group)
33
+ end
34
+ end
35
+ describe 'test attribute "id"' do
36
+ it 'should work' do
37
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
+ end
39
+ end
40
+
41
+ describe 'test attribute "title"' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ describe 'test attribute "start_year"' do
48
+ it 'should work' do
49
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
+ end
51
+ end
52
+
53
+ describe 'test attribute "end_year"' do
54
+ it 'should work' do
55
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
+ end
57
+ end
58
+
59
+ describe 'test attribute "current_course"' do
60
+ it 'should work' do
61
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
62
+ end
63
+ end
64
+
65
+ end
@@ -0,0 +1,53 @@
1
+ =begin
2
+ #UniEnv Core API
3
+
4
+ #Документация по API UniEnv
5
+
6
+ OpenAPI spec version: v1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.24-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+ require 'date'
16
+
17
+ # Unit tests for SwaggerClient::Institute
18
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
19
+ # Please update as you see appropriate
20
+ describe 'Institute' do
21
+ before do
22
+ # run before each test
23
+ @instance = SwaggerClient::Institute.new
24
+ end
25
+
26
+ after do
27
+ # run after each test
28
+ end
29
+
30
+ describe 'test an instance of Institute' do
31
+ it 'should create an instance of Institute' do
32
+ expect(@instance).to be_instance_of(SwaggerClient::Institute)
33
+ end
34
+ end
35
+ describe 'test attribute "id"' do
36
+ it 'should work' do
37
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
+ end
39
+ end
40
+
41
+ describe 'test attribute "title"' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ describe 'test attribute "short_title"' do
48
+ it 'should work' do
49
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,99 @@
1
+ =begin
2
+ #UniEnv Core API
3
+
4
+ #Документация по API UniEnv
5
+
6
+ OpenAPI spec version: v1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.24-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+ require 'date'
16
+
17
+ # Unit tests for SwaggerClient::Profile
18
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
19
+ # Please update as you see appropriate
20
+ describe 'Profile' do
21
+ before do
22
+ # run before each test
23
+ @instance = SwaggerClient::Profile.new
24
+ end
25
+
26
+ after do
27
+ # run after each test
28
+ end
29
+
30
+ describe 'test an instance of Profile' do
31
+ it 'should create an instance of Profile' do
32
+ expect(@instance).to be_instance_of(SwaggerClient::Profile)
33
+ end
34
+ end
35
+ describe 'test attribute "id"' do
36
+ it 'should work' do
37
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
+ end
39
+ end
40
+
41
+ describe 'test attribute "email"' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ describe 'test attribute "first_name"' do
48
+ it 'should work' do
49
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
+ end
51
+ end
52
+
53
+ describe 'test attribute "last_name"' do
54
+ it 'should work' do
55
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
+ end
57
+ end
58
+
59
+ describe 'test attribute "middle_name"' do
60
+ it 'should work' do
61
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
62
+ end
63
+ end
64
+
65
+ describe 'test attribute "role"' do
66
+ it 'should work' do
67
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
68
+ # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["superadmin", "admin", "teacher", "student"])
69
+ # validator.allowable_values.each do |value|
70
+ # expect { @instance.role = value }.not_to raise_error
71
+ # end
72
+ end
73
+ end
74
+
75
+ describe 'test attribute "student_group"' do
76
+ it 'should work' do
77
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
78
+ end
79
+ end
80
+
81
+ describe 'test attribute "institute"' do
82
+ it 'should work' do
83
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
84
+ end
85
+ end
86
+
87
+ describe 'test attribute "photo_url"' do
88
+ it 'should work' do
89
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
90
+ end
91
+ end
92
+
93
+ describe 'test attribute "gitlab_auth_time"' do
94
+ it 'should work' do
95
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
96
+ end
97
+ end
98
+
99
+ end
@@ -0,0 +1,111 @@
1
+ =begin
2
+ #UniEnv Core API
3
+
4
+ #Документация по API UniEnv
5
+
6
+ OpenAPI spec version: v1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.24-SNAPSHOT
10
+
11
+ =end
12
+
13
+ # load the gem
14
+ require 'swagger_client'
15
+
16
+ # The following was generated by the `rspec --init` command. Conventionally, all
17
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
18
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
19
+ # this file to always be loaded, without a need to explicitly require it in any
20
+ # files.
21
+ #
22
+ # Given that it is always loaded, you are encouraged to keep this file as
23
+ # light-weight as possible. Requiring heavyweight dependencies from this file
24
+ # will add to the boot time of your test suite on EVERY test run, even for an
25
+ # individual file that may not need all of that loaded. Instead, consider making
26
+ # a separate helper file that requires the additional dependencies and performs
27
+ # the additional setup, and require it from the spec files that actually need
28
+ # it.
29
+ #
30
+ # The `.rspec` file also contains a few flags that are not defaults but that
31
+ # users commonly want.
32
+ #
33
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
34
+ RSpec.configure do |config|
35
+ # rspec-expectations config goes here. You can use an alternate
36
+ # assertion/expectation library such as wrong or the stdlib/minitest
37
+ # assertions if you prefer.
38
+ config.expect_with :rspec do |expectations|
39
+ # This option will default to `true` in RSpec 4. It makes the `description`
40
+ # and `failure_message` of custom matchers include text for helper methods
41
+ # defined using `chain`, e.g.:
42
+ # be_bigger_than(2).and_smaller_than(4).description
43
+ # # => "be bigger than 2 and smaller than 4"
44
+ # ...rather than:
45
+ # # => "be bigger than 2"
46
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
47
+ end
48
+
49
+ # rspec-mocks config goes here. You can use an alternate test double
50
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
51
+ config.mock_with :rspec do |mocks|
52
+ # Prevents you from mocking or stubbing a method that does not exist on
53
+ # a real object. This is generally recommended, and will default to
54
+ # `true` in RSpec 4.
55
+ mocks.verify_partial_doubles = true
56
+ end
57
+
58
+ # The settings below are suggested to provide a good initial experience
59
+ # with RSpec, but feel free to customize to your heart's content.
60
+ =begin
61
+ # These two settings work together to allow you to limit a spec run
62
+ # to individual examples or groups you care about by tagging them with
63
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
64
+ # get run.
65
+ config.filter_run :focus
66
+ config.run_all_when_everything_filtered = true
67
+
68
+ # Allows RSpec to persist some state between runs in order to support
69
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
70
+ # you configure your source control system to ignore this file.
71
+ config.example_status_persistence_file_path = "spec/examples.txt"
72
+
73
+ # Limits the available syntax to the non-monkey patched syntax that is
74
+ # recommended. For more details, see:
75
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
76
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
77
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
78
+ config.disable_monkey_patching!
79
+
80
+ # This setting enables warnings. It's recommended, but in some cases may
81
+ # be too noisy due to issues in dependencies.
82
+ config.warnings = true
83
+
84
+ # Many RSpec users commonly either run the entire suite or an individual
85
+ # file, and it's useful to allow more verbose output when running an
86
+ # individual spec file.
87
+ if config.files_to_run.one?
88
+ # Use the documentation formatter for detailed output,
89
+ # unless a formatter has already been configured
90
+ # (e.g. via a command-line flag).
91
+ config.default_formatter = 'doc'
92
+ end
93
+
94
+ # Print the 10 slowest examples and example groups at the
95
+ # end of the spec run, to help surface which specs are running
96
+ # particularly slow.
97
+ config.profile_examples = 10
98
+
99
+ # Run specs in random order to surface order dependencies. If you find an
100
+ # order dependency and want to debug it, you can fix the order by providing
101
+ # the seed, which is printed after each run.
102
+ # --seed 1234
103
+ config.order = :random
104
+
105
+ # Seed global randomization in this process using the `--seed` CLI option.
106
+ # Setting this allows you to use `--seed` to deterministically reproduce
107
+ # test failures related to randomization by passing the same `--seed` value
108
+ # as the one that triggered the failure.
109
+ Kernel.srand config.seed
110
+ =end
111
+ end
@@ -0,0 +1,3 @@
1
+ module UnienvApi
2
+ VERSION = '1.0.0'
3
+ end
data/lib/unienv_api.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'oauth2'
2
+ require 'swagger_client'
3
+
4
+ class UniEnv
5
+ # Инициализация инстанса класса
6
+ # :param client_id: client id
7
+ # :param client_secret: client secret
8
+ # :param redirect_uri: адрес, на который пользователь будет возвращен после авторизации
9
+ def initialize(client_id, client_secret, redirect_uri)
10
+ @unienv = OAuth2::Client.new(client_id, client_secret, { site: 'https://core.uenv.ru', redirect_uri: redirect_uri} )
11
+ end
12
+
13
+ # Возвращает ссылку для переадресации пользователя на страницу авторизации
14
+ def authorize
15
+ @unienv.auth_code.authorize_url
16
+ end
17
+
18
+ # Получение access token c дополнительными данными для выполнения следующих запросов
19
+ # :param code: код авторизации
20
+ def get_token(code)
21
+ @token = @unienv.auth_code.get_token(code)
22
+ @token.token
23
+ end
24
+
25
+ # Отзыв токена
26
+ def revoke_token
27
+ header = { 'Content-Type' => 'application/x-www-form-urlencoded' }
28
+ body = { token: @token.token, client_id: @unienv.id, client_secret: @unienv.secret }
29
+ @response = @unienv.request(:post, 'https://uenv-core.kpfu.ru/oauth/revoke_token/', {header: header, body: body})
30
+ @response.status == 200? 'Токен отозван' : "Не удалось отозвать токен - #{@response.response_body.to_s}"
31
+ end
32
+
33
+ # Обновление токена
34
+ def refresh_token
35
+ @token.refresh!.token
36
+ end
37
+
38
+ # Получение профиля
39
+ def get_profile
40
+ SwaggerClient.configure.access_token = @token.token
41
+ @api = SwaggerClient::ProfileApi.new
42
+ @api.profile_get
43
+ end
44
+ end