add another user to the test setup

This commit is contained in:
codl 2017-11-29 21:42:20 +01:00
pare 0f753e621a
commit 309cc26ded
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 6CD7C8891ED1233A
S'han modificat 4 arxius amb 134 adicions i 78 eliminacions

Veure arxiu

@ -1,27 +1,27 @@
interactions: interactions:
- request: - request:
body: redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&password=mastodonadmin&username=admin%40localhost%3A3000&grant_type=password&client_id=__MASTODON_PY_TEST_ID&client_secret=__MASTODON_PY_TEST_SECRET&scope=read+write+follow body: !!python/unicode username=admin%40localhost%3A3000&password=mastodonadmin&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&client_id=__MASTODON_PY_TEST_CLIENT_ID&scope=read+write+follow&client_secret=__MASTODON_PY_TEST_CLIENT_SECRET&grant_type=password
headers: headers:
Accept: ['*/*'] Accept: ['*/*']
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive] Connection: [keep-alive]
Content-Length: ['221'] Content-Length: ['235']
Content-Type: [application/x-www-form-urlencoded] Content-Type: [application/x-www-form-urlencoded]
User-Agent: [python-requests/2.18.4] User-Agent: [python-requests/2.18.4]
method: POST method: POST
uri: http://localhost:3000/oauth/token uri: http://localhost:3000/oauth/token
response: response:
body: {string: '{"access_token":"__MASTODON_PY_TEST_TOKEN","token_type":"bearer","scope":"read body: {string: !!python/unicode '{"access_token":"__MASTODON_PY_TEST_ACCESS_TOKEN_2","token_type":"bearer","scope":"read
write follow","created_at":1511814180}'} write follow","created_at":1511992220}'}
headers: headers:
Cache-Control: [no-store] cache-control: [no-store]
Content-Type: [application/json; charset=utf-8] content-length: ['126']
ETag: [W/"f6a22ef91276cdcde8f09c8186d2d41d"] content-type: [application/json; charset=utf-8]
Pragma: [no-cache] etag: [W/"7f19440d01a73bd9685be7280866fa5b"]
Transfer-Encoding: [chunked] pragma: [no-cache]
Vary: ['Accept-Encoding, Origin'] transfer-encoding: [chunked]
X-Request-Id: [85cb59f1-b92a-4ff8-8a49-c09bed55eb98] vary: ['Accept-Encoding, Origin']
X-Runtime: ['0.077197'] x-request-id: [d33af1b6-ae04-495f-9a8c-720b570e98a9]
content-length: ['117'] x-runtime: ['0.244819']
status: {code: 200, message: OK} status: {code: 200, message: OK}
version: 1 version: 1

Veure arxiu

@ -1,52 +1,54 @@
interactions: interactions:
- request: - request:
body: redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&password=mastodonadmin&username=admin%40localhost%3A3000&grant_type=password&client_id=__MASTODON_PY_TEST_ID&client_secret=__MASTODON_PY_TEST_SECRET&scope=read+write+follow body: !!python/unicode username=admin%40localhost%3A3000&password=mastodonadmin&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&client_id=__MASTODON_PY_TEST_CLIENT_ID&scope=read+write+follow&client_secret=__MASTODON_PY_TEST_CLIENT_SECRET&grant_type=password
headers: headers:
Accept: ['*/*'] Accept: ['*/*']
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive] Connection: [keep-alive]
Content-Length: ['221'] Content-Length: ['235']
Content-Type: [application/x-www-form-urlencoded] Content-Type: [application/x-www-form-urlencoded]
User-Agent: [python-requests/2.18.4] User-Agent: [python-requests/2.18.4]
method: POST method: POST
uri: http://localhost:3000/oauth/token uri: http://localhost:3000/oauth/token
response: response:
body: {string: '{"access_token":"__MASTODON_PY_TEST_TOKEN","token_type":"bearer","scope":"read body: {string: !!python/unicode '{"access_token":"__MASTODON_PY_TEST_ACCESS_TOKEN_2","token_type":"bearer","scope":"read
write follow","created_at":1511814180}'} write follow","created_at":1511992220}'}
headers: headers:
Cache-Control: [no-store] cache-control: [no-store]
Content-Type: [application/json; charset=utf-8] content-length: ['126']
ETag: [W/"f77400f50590c94b55a861fb6d432464"] content-type: [application/json; charset=utf-8]
Pragma: [no-cache] etag: [W/"d69940161df215958096efeb1a959d12"]
Transfer-Encoding: [chunked] pragma: [no-cache]
Vary: ['Accept-Encoding, Origin'] transfer-encoding: [chunked]
X-Request-Id: [b6168343-dd9e-4a0f-9ec4-69a1de8f879a] vary: ['Accept-Encoding, Origin']
X-Runtime: ['0.080069'] x-request-id: [a05d2bef-1d32-4857-97b5-6cc4136dfd29]
content-length: ['117'] x-runtime: ['0.205660']
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: null body: null
headers: headers:
Accept: ['*/*'] Accept: ['*/*']
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_TOKEN] Authorization: [!!python/unicode Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive] Connection: [keep-alive]
User-Agent: [python-requests/2.18.4] User-Agent: [python-requests/2.18.4]
method: GET method: GET
uri: http://localhost:3000/api/v1/accounts/verify_credentials uri: http://localhost:3000/api/v1/accounts/verify_credentials
response: response:
body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"admin","locked":false,"created_at":"2017-08-02T04:15:27.248Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/system/accounts/avatars/000/000/001/original/69910b47243ddb47.png","avatar_static":"http://localhost:3000/system/accounts/avatars/000/000/001/original/69910b47243ddb47.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":2,"following_count":1,"statuses_count":16,"source":{"privacy":"public","sensitive":false,"note":""}}'} body: {string: !!python/unicode '{"id":"1","username":"admin","acct":"admin","display_name":"codltest","locked":false,"created_at":"2017-07-01T17:09:15.621Z","note":"\u003cp\u003ehello
:)\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","avatar_static":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":50,"source":{"privacy":"public","sensitive":false,"note":"hello
:)"}}'}
headers: headers:
Cache-Control: ['max-age=0, private, must-revalidate'] cache-control: ['max-age=0, private, must-revalidate']
Content-Type: [application/json; charset=utf-8] content-length: ['669']
ETag: [W/"622f72a29f8398775e2abff7cd51dbac"] content-type: [application/json; charset=utf-8]
Transfer-Encoding: [chunked] etag: [W/"05183e2c68a77cfb9877fc356465a322"]
Vary: ['Accept-Encoding, Origin'] transfer-encoding: [chunked]
X-Content-Type-Options: [nosniff] vary: ['Accept-Encoding, Origin']
X-Frame-Options: [SAMEORIGIN] x-content-type-options: [nosniff]
X-Request-Id: [3852d894-50be-4342-a0e6-f9df2ddf5926] x-frame-options: [SAMEORIGIN]
X-Runtime: ['0.029510'] x-request-id: [0cdc8a2f-6deb-4437-bd96-4e7178e1b9cd]
X-XSS-Protection: [1; mode=block] x-runtime: ['0.230997']
content-length: ['650'] x-xss-protection: [1; mode=block]
status: {code: 200, message: OK} status: {code: 200, message: OK}
version: 1 version: 1

Veure arxiu

@ -1,21 +1,28 @@
import pytest import pytest
def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN'):
import mastodon
return mastodon.Mastodon(
api_base_url='http://localhost:3000',
client_id='__MASTODON_PY_TEST_CLIENT_ID',
client_secret='__MASTODON_PY_TEST_CLIENT_SECRET',
access_token=access_token)
@pytest.fixture @pytest.fixture
def api(): def api():
import mastodon return _api()
return mastodon.Mastodon(
api_base_url='http://localhost:3000',
client_id='__MASTODON_PY_TEST_ID', @pytest.fixture
client_secret='__MASTODON_PY_TEST_SECRET', def api2():
access_token='__MASTODON_PY_TEST_TOKEN') return _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN_2')
@pytest.fixture @pytest.fixture
def api_anonymous(): def api_anonymous():
import mastodon return _api(access_token=None)
return mastodon.Mastodon(
api_base_url='http://localhost:3000',
client_id='__MASTODON_PY_TEST_ID',
client_secret='__MASTODON_PY_TEST_SECRET')
@pytest.fixture() @pytest.fixture()
def status(api): def status(api):

Veure arxiu

@ -1,37 +1,84 @@
WITH new_app AS ( DELETE FROM oauth_access_tokens WHERE id = 6543210987654321;
INSERT INTO oauth_applications ( DELETE FROM oauth_access_tokens WHERE id = 1234567890123456;
name, DELETE FROM oauth_applications WHERE id = 1234567890123456;
uid, DELETE FROM users WHERE id = 1234567890123456;
secret, DELETE FROM accounts WHERE id = 1234567890123456;
redirect_uri,
scopes, INSERT INTO accounts (
owner_type, id,
owner_id, username,
created_at, created_at,
updated_at updated_at
) VALUES ( ) VALUES (
'Mastodon.py test suite', 1234567890123456,
'__MASTODON_PY_TEST_ID', 'mastodonpy_test',
'__MASTODON_PY_TEST_SECRET', now(),
'urn:ietf:wg:oauth:2.0:oob', now()
'read write follow', );
'User',
1, INSERT INTO users (
now(), id,
now() email,
) account_id,
RETURNING id created_at,
) updated_at,
confirmed_at,
locale
) VALUES (
1234567890123456,
'mastodonpy_test@localhost:3000',
1234567890123456,
now(),
now(),
now(),
'ja' -- japanese locale for unicode testing :p
);
INSERT INTO oauth_applications (
id,
name,
uid,
secret,
redirect_uri,
scopes,
owner_type,
owner_id,
created_at,
updated_at
) VALUES (
1234567890123456,
'Mastodon.py test suite',
'__MASTODON_PY_TEST_CLIENT_ID',
'__MASTODON_PY_TEST_CLIENT_SECRET',
'urn:ietf:wg:oauth:2.0:oob',
'read write follow',
'User',
1234567890123456,
now(),
now()
);
INSERT INTO oauth_access_tokens ( INSERT INTO oauth_access_tokens (
id,
token, token,
scopes, scopes,
application_id, application_id,
resource_owner_id, resource_owner_id,
created_at created_at
) SELECT ) VALUES (
'__MASTODON_PY_TEST_TOKEN', 1234567890123456,
'__MASTODON_PY_TEST_ACCESS_TOKEN',
'read write follow', 'read write follow',
new_app.id, 1234567890123456,
1234567890123456,
now()
), (
6543210987654321,
'__MASTODON_PY_TEST_ACCESS_TOKEN_2',
'read write follow',
1234567890123456,
1, 1,
now() now()
FROM new_app; );