mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 19:37:55 +08:00
d04ba4b3b2
* DEPRECATION: Remove support for api creds in query params
This commit removes support for api credentials in query params except
for a few whitelisted routes like rss/json feeds and the handle_mail
route.
Several tests were written to valid these changes, but the bulk of the
spec changes are just switching them over to use header based auth so
that they will pass without changing what they were actually testing.
Original commit that notified admins this change was coming was created
over 3 months ago: 2db2003187
* fix tests
* Also allow iCalendar feeds
Co-authored-by: Rafael dos Santos Silva <xfalcox@gmail.com>
48 lines
1.1 KiB
Ruby
48 lines
1.1 KiB
Ruby
# encoding: UTF-8
|
|
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe 'invite only' do
|
|
|
|
describe '#create invite only' do
|
|
it 'can create user via API' do
|
|
|
|
SiteSetting.invite_only = true
|
|
Jobs.run_immediately!
|
|
|
|
admin = Fabricate(:admin)
|
|
api_key = Fabricate(:api_key, user: admin)
|
|
|
|
post '/users.json', params: {
|
|
name: 'bob',
|
|
username: 'bob',
|
|
password: 'strongpassword',
|
|
email: 'bob@bob.com',
|
|
}, headers: {
|
|
HTTP_API_KEY: api_key.key,
|
|
HTTP_API_USERNAME: admin.username
|
|
}
|
|
|
|
user_id = JSON.parse(response.body)["user_id"]
|
|
expect(user_id).to be > 0
|
|
|
|
# activate and approve
|
|
put "/admin/users/#{user_id}/activate.json", headers: {
|
|
HTTP_API_KEY: api_key.key,
|
|
HTTP_API_USERNAME: admin.username
|
|
}
|
|
|
|
put "/admin/users/#{user_id}/approve.json", headers: {
|
|
HTTP_API_KEY: api_key.key,
|
|
HTTP_API_USERNAME: admin.username
|
|
}
|
|
|
|
u = User.find(user_id)
|
|
expect(u.active).to eq(true)
|
|
expect(u.approved).to eq(true)
|
|
|
|
end
|
|
end
|
|
end
|