Always require authentication for asciicast upload

private-asciicasts
Marcin Kulik 10 years ago
parent 448f0eb899
commit c0b000b4df

@ -1,6 +1,8 @@
module Api
class AsciicastsController < BaseController
before_filter :ensure_authenticated!, only: :create
respond_to :html, only: [:show]
attr_reader :asciicast

@ -307,10 +307,13 @@ describe "Asciicast creation" do
context 'format 1' do
subject { make_request }
let(:username) { 'kill' }
let(:token) { 'f33e6188-f53c-11e2-abf4-84a6c827e88b' }
def make_request(asciicast_path = '1/asciicast.json')
post '/api/asciicasts',
{ asciicast: fixture_file(asciicast_path, 'application/json') },
headers('kill', 'f33e6188-f53c-11e2-abf4-84a6c827e88b', 'asciinema/1.0.0 gc/go1.3 jola-amd64')
headers(username, token, 'asciinema/1.0.0 gc/go1.3 jola-amd64')
end
before { subject }
@ -405,6 +408,15 @@ describe "Asciicast creation" do
end
end
context 'when auth is not present' do
let(:username) { nil }
let(:token) { nil }
it 'returns 401 status' do
expect(response.status).to eq(401)
end
end
end
end

Loading…
Cancel
Save