stash-sword 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af0fd967341aed3754e732ab4d6b80f9a7b3b45e
4
- data.tar.gz: 2e5df91999db5694b01df4b796a5a709e3f9fad2
3
+ metadata.gz: 3b9630eb6e13c298e5510adc24a284f80cd2782d
4
+ data.tar.gz: c84b4010037183af57468e22b0b33032f989cedd
5
5
  SHA512:
6
- metadata.gz: 91af61a83ee80da3d08043c8dfcf6a6058324dbdcf6c3e4645a8cfd68e1aef7ed53a01447a1ab911c9fec31a6bdbcdef1d374552eb0f002c33ba2230e3bc96db
7
- data.tar.gz: 6aab871185203aee75de2fce19dd54090000d478a96134b6e19fe732261048ed49ce4ef33760e01cb00c904ab2f82bf608935088e0561c0c56aecd69fb423af6
6
+ metadata.gz: 1ab2af3fea1f8d220075abe287baeb531265a4483814a7aae7766721c649d5a62099368d943a550e6a0ff6bebc04a36e250d9390df7952bb1f6089624de67e6d
7
+ data.tar.gz: ee6a6857b1c898f73312b60086a6cd3cb0af2ca9a177dbcdeca489ab60af8f9cd1c0bd04a9b2f9b61d17ffb77eee24abe56768b062ea680010b875f9b9d3141b
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.3 (15 August 2016)
2
+
3
+ - Use 2.0.0 release version of `rest-client` to fix issues with cookie handling in redirection
4
+
1
5
  ## 0.1.2 (11 July 2016)
2
6
 
3
7
  - Use `Content-disposition: attachment` (per [SWORD spec](http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html))
@@ -55,6 +55,7 @@ module Stash
55
55
  #
56
56
  # @param edit_iri [URI, String] the Atom Edit-IRI
57
57
  # @param zipfile [String] the zipfile path
58
+ # @return [Integer] the response code (if the request succeeds)
58
59
  def update(edit_iri:, zipfile:)
59
60
  log.debug("Stash::Sword::Client.update(edit_iri: #{edit_iri}, zipfile: #{zipfile})")
60
61
  uri = to_uri(edit_iri).to_s
@@ -4,7 +4,7 @@ module Stash
4
4
  NAME = 'stash-sword'.freeze
5
5
 
6
6
  # The version of this gem
7
- VERSION = '0.1.2'.freeze
7
+ VERSION = '0.1.3'.freeze
8
8
 
9
9
  # The copyright notice for this gem
10
10
  COPYRIGHT = 'Copyright (c) 2016 The Regents of the University of California'.freeze
@@ -53,8 +53,19 @@ module Stash
53
53
  it 'returns the entry'
54
54
  it "gets the entry from the Edit-IRI in the Location: header if it isn't returned in the body"
55
55
  it 'forwards a success response'
56
- it 'forwards a 4xx error'
57
- it 'forwards a 5xx error'
56
+
57
+ it 'forwards a 4xx error' do
58
+ authorized_uri = collection_uri.sub('http://', "http://#{username}:#{password}@")
59
+ stub_request(:post, authorized_uri).to_return(status: [403, 'Forbidden'])
60
+ expect { client.create(zipfile: zipfile, doi: doi) }.to raise_error(RestClient::Forbidden)
61
+ end
62
+
63
+ it 'forwards a 5xx error' do
64
+ authorized_uri = collection_uri.sub('http://', "http://#{username}:#{password}@")
65
+ stub_request(:post, authorized_uri).to_return(status: [500, 'Internal Server Error'])
66
+ expect { client.create(zipfile: zipfile, doi: doi) }.to raise_error(RestClient::InternalServerError)
67
+ end
68
+
58
69
  it 'forwards an internal exception'
59
70
  end
60
71
 
@@ -65,7 +76,8 @@ module Stash
65
76
 
66
77
  stub_request(:put, authorized_uri)
67
78
 
68
- client.update(edit_iri: edit_iri, zipfile: zipfile)
79
+ code = client.update(edit_iri: edit_iri, zipfile: zipfile)
80
+ expect(code).to eq(200)
69
81
 
70
82
  md5 = Digest::MD5.file(zipfile).to_s
71
83
 
@@ -105,8 +117,21 @@ module Stash
105
117
 
106
118
  it 'does something clever and asynchronous'
107
119
  it 'forwards a success response'
108
- it 'forwards a 4xx error'
109
- it 'forwards a 5xx error'
120
+
121
+ it 'forwards a 4xx error' do
122
+ edit_iri = "http://merritt.cdlib.org/sword/v2/object/#{doi}"
123
+ authorized_uri = edit_iri.sub('http://', "http://#{username}:#{password}@")
124
+ stub_request(:put, authorized_uri).to_return(status: [403, 'Forbidden'])
125
+ expect { client.update(edit_iri: edit_iri, zipfile: zipfile) }.to raise_error(RestClient::Forbidden)
126
+ end
127
+
128
+ it 'forwards a 5xx error' do
129
+ edit_iri = "http://merritt.cdlib.org/sword/v2/object/#{doi}"
130
+ authorized_uri = edit_iri.sub('http://', "http://#{username}:#{password}@")
131
+ stub_request(:put, authorized_uri).to_return(status: [500, 'Internal Server Error'])
132
+ expect { client.update(edit_iri: edit_iri, zipfile: zipfile) }.to raise_error(RestClient::InternalServerError)
133
+ end
134
+
110
135
  it 'forwards an internal exception'
111
136
  end
112
137
 
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_dependency 'rest-client', '2.0.0.rc2'
27
+ spec.add_dependency 'rest-client', '~> 2.0', '2.0.0'
28
28
  spec.add_dependency 'typesafe_enum', '~> 0.1', '>= 0.1.7'
29
29
  spec.add_dependency 'xml-mapping_extensions', '~> 0.4', '>= 0.4.1'
30
30
 
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stash-sword
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
17
20
  - - '='
18
21
  - !ruby/object:Gem::Version
19
- version: 2.0.0.rc2
22
+ version: 2.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
24
30
  - - '='
25
31
  - !ruby/object:Gem::Version
26
- version: 2.0.0.rc2
32
+ version: 2.0.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: typesafe_enum
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -224,8 +230,6 @@ files:
224
230
  - lib/stash/sword/module_info.rb
225
231
  - lib/stash/sword/namespace.rb
226
232
  - lib/stash/sword/sequence_io.rb
227
- - notes/Dash_Submission_To_Merritt.txt
228
- - notes/service-document.xml
229
233
  - spec/.rubocop.yml
230
234
  - spec/data/deposit_receipt_merritt.xml
231
235
  - spec/data/deposit_receipt_spec.xml
@@ -1,40 +0,0 @@
1
- Status of submission is tracked - merritt_response {PROCESSING, “User not authorized for Merritt submission”,
2
-
3
- How is dublincore called?
4
-
5
- Review & Submit button —> record.review()
6
- creates datacite.xml file and places it in the uploads/<local_id>/ directory
7
-
8
- Submit button —> record.send_archive_to_merritt
9
-
10
- Set up the user_email request headers
11
- Create a new thread
12
- Record.Generate Merritt Zip()
13
- Record.Send Archive to Merritt
14
- Create a submission Log
15
-
16
-
17
- If submission successful, remove files from local storage and add logging information
18
- Record.Purge_Files()
19
-
20
- Generate_Merritt_Zip()
21
- set file path to uploads_dir - this is a linked directory shared/uploads so it will stay persistent across releases
22
- local_id is used to name the uploads directory for a dataset.
23
- calls self.review
24
- calls self.dublincore
25
- calls self.dataone
26
- creates the zip file
27
- purges all temp files, etc
28
-
29
- Record.Send_Archive_to_merritt
30
- gets info to send in curl command from MERRITT_CONFIG and user and camps
31
- sends curl command - no notification sent if no email
32
- No DOI/EZID is not created. Merritt does this.
33
- returns sys_output
34
-
35
-
36
- SWORD - Slug identifier is the local_id
37
-
38
-
39
-
40
- if @user_email.nil?
41
  sys_output = "curl --insecure --verbose -u #{merritt_username}:#{merritt_password} -F \"file=@./#{DATASHARE_CONFIG['uploads_dir']}/#{self.local_id}/#{self.local_id}.zip\" -F \"type=container\" -F \"submitter=Dash/#{external_id}\" -F \"responseForm=xml\" -F \"profile=#{merritt_profile}\" -F \"localIdentifier=#{self.local_id}\" #{merritt_endpoint} 2>&1"
42
1
  else
43
2
  sys_output = "curl --insecure --verbose -u #{merritt_username}:#{merritt_password} -F \"file=@./#{DATASHARE_CONFIG['uploads_dir']}/#{self.local_id}/#{self.local_id}.zip\" -F \"notification=#{@user_email}\" -F \"type=container\" -F \"submitter=Dash/#{external_id}\" -F \"responseForm=xml\" -F \"profile=#{merritt_profile}\" -F \"localIdentifier=#{self.local_id}\" #{merritt_endpoint} 2>&1"
44
3
  end
@@ -1,15 +0,0 @@
1
- <service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom">
2
- <workspace>
3
- <atom:title type="text">Merritt</atom:title>
4
- <collection href="http://merritt.cdlib.org/sword/v2/dash_ucb">
5
- <atom:title type="text">UCB Dash</atom:title>
6
- <accept>*/*</accept>
7
- <accept alternate="multipart-related">*/*</accept>
8
- <mediation xmlns="http://purl.org/net/sword/terms/">true</mediation>
9
- <acceptPackaging xmlns="http://purl.org/net/sword/terms/">http://purl.org/net/sword/package/SimpleZip</acceptPackaging>
10
- </collection>
11
- </workspace>
12
- <generator xmlns="http://www.w3.org/2005/Atom" uri="http://www.swordapp.org/" version="2.0" />
13
- <version xmlns="http://purl.org/net/sword/terms/">2.0</version>
14
- <maxUploadSize xmlns="http://purl.org/net/sword/terms/">10000000</maxUploadSize>
15
- </service>