@@ -5,12 +5,12 | |||
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 |
# |
|
|
8 | # | |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 |
# |
|
|
13 | # | |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
@@ -24,12 +24,12 class ApiTest::AttachmentsTest < ActionController::IntegrationTest | |||
|
24 | 24 | Setting.rest_api_enabled = '1' |
|
25 | 25 | Attachment.storage_path = "#{Rails.root}/test/fixtures/files" |
|
26 | 26 | end |
|
27 | ||
|
27 | ||
|
28 | 28 | context "/attachments/:id" do |
|
29 | 29 | context "GET" do |
|
30 | 30 | should "return the attachment" do |
|
31 | 31 | get '/attachments/7.xml', {}, :authorization => credentials('jsmith') |
|
32 | ||
|
32 | ||
|
33 | 33 | assert_response :success |
|
34 | 34 | assert_equal 'application/xml', @response.content_type |
|
35 | 35 | assert_tag :tag => 'attachment', |
@@ -46,32 +46,32 class ApiTest::AttachmentsTest < ActionController::IntegrationTest | |||
|
46 | 46 | } |
|
47 | 47 | } |
|
48 | 48 | end |
|
49 | ||
|
49 | ||
|
50 | 50 | should "deny access without credentials" do |
|
51 | 51 | get '/attachments/7.xml' |
|
52 | ||
|
52 | ||
|
53 | 53 | assert_response 401 |
|
54 | 54 | end |
|
55 | 55 | end |
|
56 | 56 | end |
|
57 | ||
|
57 | ||
|
58 | 58 | context "/attachments/download/:id/:filename" do |
|
59 | 59 | context "GET" do |
|
60 | 60 | should "return the attachment content" do |
|
61 | 61 | get '/attachments/download/7/archive.zip', {}, :authorization => credentials('jsmith') |
|
62 | ||
|
62 | ||
|
63 | 63 | assert_response :success |
|
64 | 64 | assert_equal 'application/octet-stream', @response.content_type |
|
65 | 65 | end |
|
66 | ||
|
66 | ||
|
67 | 67 | should "deny access without credentials" do |
|
68 | 68 | get '/attachments/download/7/archive.zip' |
|
69 | ||
|
69 | ||
|
70 | 70 | assert_response 302 |
|
71 | 71 | end |
|
72 | 72 | end |
|
73 | 73 | end |
|
74 | ||
|
74 | ||
|
75 | 75 | def credentials(user, password=nil) |
|
76 | 76 | ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user) |
|
77 | 77 | end |
General Comments 0
You need to be logged in to leave comments.
Login now