diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/gitlab_net_spec.rb | 27 | ||||
-rw-r--r-- | spec/vcr_cassettes/lfs-authenticate-ok-download.yml | 46 | ||||
-rw-r--r-- | spec/vcr_cassettes/lfs-authenticate-ok-upload.yml (renamed from spec/vcr_cassettes/lfs-authenticate-ok.yml) | 4 |
3 files changed, 69 insertions, 8 deletions
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb index 0656084..07b772b 100644 --- a/spec/gitlab_net_spec.rb +++ b/spec/gitlab_net_spec.rb @@ -67,12 +67,27 @@ describe GitlabNet, vcr: true do describe '#lfs_authenticate' do context 'lfs authentication succeeded' do - it 'should return the correct data' do - VCR.use_cassette('lfs-authenticate-ok') do - lfs_access = gitlab_net.lfs_authenticate(key, project) - expect(lfs_access.username).to eq('root') - expect(lfs_access.lfs_token).to eq('Hyzhyde_wLUeyUQsR3tHGTG8eNocVQm4ssioTEsBSdb6KwCSzQ') - expect(lfs_access.repository_http_path).to eq(URI.join(internal_api_endpoint.sub('api/v4', ''), project).to_s) + let(:repository_http_path) { URI.join(internal_api_endpoint.sub('api/v4', ''), project).to_s } + + context 'for download operation' do + it 'should return the correct data' do + VCR.use_cassette('lfs-authenticate-ok-download') do + lfs_access = gitlab_net.lfs_authenticate(key, project, 'download') + expect(lfs_access.username).to eq('root') + expect(lfs_access.lfs_token).to eq('Hyzhyde_wLUeyUQsR3tHGTG8eNocVQm4ssioTEsBSdb6KwCSzQ') + expect(lfs_access.repository_http_path).to eq(repository_http_path) + end + end + end + + context 'for upload operation' do + it 'should return the correct data' do + VCR.use_cassette('lfs-authenticate-ok-upload') do + lfs_access = gitlab_net.lfs_authenticate(key, project, 'upload') + expect(lfs_access.username).to eq('root') + expect(lfs_access.lfs_token).to eq('Hyzhyde_wLUeyUQsR3tHGTG8eNocVQm4ssioTEsBSdb6KwCSzQ') + expect(lfs_access.repository_http_path).to eq(repository_http_path) + end end end end diff --git a/spec/vcr_cassettes/lfs-authenticate-ok-download.yml b/spec/vcr_cassettes/lfs-authenticate-ok-download.yml new file mode 100644 index 0000000..e832c90 --- /dev/null +++ b/spec/vcr_cassettes/lfs-authenticate-ok-download.yml @@ -0,0 +1,46 @@ +--- +http_interactions: +- request: + method: post + uri: http://localhost:3000/api/v4/internal/lfs_authenticate + body: + encoding: US-ASCII + string: project=gitlab-org%2Fgitlab-test.git&key_id=1&operation=download&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Length: + - '158' + Content-Type: + - application/json + Date: + - Wed, 21 Jun 2017 10:44:50 GMT + Etag: + - W/"0a8ccf1603566e521c169d5e43c86cd2" + Vary: + - Origin + X-Frame-Options: + - SAMEORIGIN + X-Request-Id: + - d82d6071-1868-4a37-b026-65ab37f96f2f + X-Runtime: + - '0.331056' + body: + encoding: UTF-8 + string: '{"username":"root","lfs_token":"Hyzhyde_wLUeyUQsR3tHGTG8eNocVQm4ssioTEsBSdb6KwCSzQ","repository_http_path":"http://localhost:3000/gitlab-org/gitlab-test.git"}' + http_version: + recorded_at: Wed, 21 Jun 2017 10:44:50 GMT +recorded_with: VCR 2.4.0 diff --git a/spec/vcr_cassettes/lfs-authenticate-ok.yml b/spec/vcr_cassettes/lfs-authenticate-ok-upload.yml index 929e1d5..e4fa335 100644 --- a/spec/vcr_cassettes/lfs-authenticate-ok.yml +++ b/spec/vcr_cassettes/lfs-authenticate-ok-upload.yml @@ -5,7 +5,7 @@ http_interactions: uri: http://localhost:3000/api/v4/internal/lfs_authenticate body: encoding: US-ASCII - string: project=gitlab-org%2Fgitlab-test.git&key_id=1&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A + string: project=gitlab-org%2Fgitlab-test.git&key_id=1&operation=upload&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A headers: Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 @@ -41,6 +41,6 @@ http_interactions: body: encoding: UTF-8 string: '{"username":"root","lfs_token":"Hyzhyde_wLUeyUQsR3tHGTG8eNocVQm4ssioTEsBSdb6KwCSzQ","repository_http_path":"http://localhost:3000/gitlab-org/gitlab-test.git"}' - http_version: + http_version: recorded_at: Wed, 21 Jun 2017 10:44:50 GMT recorded_with: VCR 2.4.0 |