0
0
Fork 0

Change read:me scope to profile scope (#30357)

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Emelia Smith 2024-06-06 09:30:10 +02:00 committed by GitHub
parent 569b7d2f25
commit e02d23b549
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 68 additions and 9 deletions

View file

@ -130,11 +130,20 @@ namespace :tests do
# This is checking the attribute rather than the method, to avoid the legacy fallback
# and ensure the data has been migrated
unless Account.find_local('qcuser').user[:otp_secret] == 'anotpsecretthatshouldbeencrypted'
puts "DEBUG: #{Account.find_local('qcuser').user.inspect}"
puts 'OTP secret for user not preserved as expected'
exit(1)
end
unless Doorkeeper::Application.find(2)[:scopes] == 'write:accounts profile'
puts 'Application OAuth scopes not rewritten as expected'
exit(1)
end
unless Doorkeeper::Application.find(2).access_tokens.first[:scopes] == 'write:accounts profile'
puts 'OAuth access token scopes not rewritten as expected'
exit(1)
end
puts 'No errors found. Database state is consistent with a successful migration process.'
end
@ -152,6 +161,23 @@ namespace :tests do
VALUES
(1, 'https://example.com/users/foobar', 'foobar@example.com', now(), now()),
(1, 'https://example.com/users/foobar', 'foobar@example.com', now(), now());
/* Doorkeeper records
While the `read:me` scope was technically not valid in 3.3.0,
it is still useful for the purposes of testing the `ChangeReadMeScopeToProfile`
migration.
*/
INSERT INTO "oauth_applications"
(id, name, uid, secret, redirect_uri, scopes, created_at, updated_at)
VALUES
(2, 'foo', 'foo', 'foo', 'https://example.com/#foo', 'write:accounts read:me', now(), now()),
(3, 'bar', 'bar', 'bar', 'https://example.com/#bar', 'read:me', now(), now());
INSERT INTO "oauth_access_tokens"
(token, application_id, scopes, resource_owner_id, created_at)
VALUES
('secret', 2, 'write:accounts read:me', 4, now());
SQL
end