mirror of
https://github.com/neocities/neocities.git
synced 2025-07-22 10:36:07 +02:00
API key support
This commit is contained in:
parent
73ec613283
commit
1274e9fa63
8 changed files with 93 additions and 17 deletions
|
@ -217,6 +217,26 @@ describe 'api upload' do
|
|||
res[:error_type].must_equal 'missing_files'
|
||||
end
|
||||
|
||||
it 'succeeds with valid api key' do
|
||||
create_site
|
||||
@site.api_key.must_equal nil
|
||||
@site.generate_api_key!
|
||||
@site.reload.api_key.wont_equal nil
|
||||
header 'Authorization', "Bearer #{@site.api_key}"
|
||||
post '/api/upload', 'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||
res[:result].must_equal 'success'
|
||||
site_file_exists?('test.jpg').must_equal true
|
||||
end
|
||||
|
||||
it 'fails with bad api key' do
|
||||
create_site
|
||||
@site.generate_api_key!
|
||||
header 'Authorization', "Bearer zerocool"
|
||||
post '/api/upload', 'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||
res[:result].must_equal 'error'
|
||||
res[:error_type].must_equal 'invalid_auth'
|
||||
end
|
||||
|
||||
=begin
|
||||
# Getting too slow to run this test
|
||||
it 'fails with too many files' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue