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:
- 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:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['221']
Content-Length: ['235']
Content-Type: [application/x-www-form-urlencoded]
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/oauth/token
response:
body: {string: '{"access_token":"__MASTODON_PY_TEST_TOKEN","token_type":"bearer","scope":"read
write follow","created_at":1511814180}'}
body: {string: !!python/unicode '{"access_token":"__MASTODON_PY_TEST_ACCESS_TOKEN_2","token_type":"bearer","scope":"read
write follow","created_at":1511992220}'}
headers:
Cache-Control: [no-store]
Content-Type: [application/json; charset=utf-8]
ETag: [W/"f6a22ef91276cdcde8f09c8186d2d41d"]
Pragma: [no-cache]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Request-Id: [85cb59f1-b92a-4ff8-8a49-c09bed55eb98]
X-Runtime: ['0.077197']
content-length: ['117']
cache-control: [no-store]
content-length: ['126']
content-type: [application/json; charset=utf-8]
etag: [W/"7f19440d01a73bd9685be7280866fa5b"]
pragma: [no-cache]
transfer-encoding: [chunked]
vary: ['Accept-Encoding, Origin']
x-request-id: [d33af1b6-ae04-495f-9a8c-720b570e98a9]
x-runtime: ['0.244819']
status: {code: 200, message: OK}
version: 1

Veure arxiu

@ -1,52 +1,54 @@
interactions:
- 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:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['221']
Content-Length: ['235']
Content-Type: [application/x-www-form-urlencoded]
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/oauth/token
response:
body: {string: '{"access_token":"__MASTODON_PY_TEST_TOKEN","token_type":"bearer","scope":"read
write follow","created_at":1511814180}'}
body: {string: !!python/unicode '{"access_token":"__MASTODON_PY_TEST_ACCESS_TOKEN_2","token_type":"bearer","scope":"read
write follow","created_at":1511992220}'}
headers:
Cache-Control: [no-store]
Content-Type: [application/json; charset=utf-8]
ETag: [W/"f77400f50590c94b55a861fb6d432464"]
Pragma: [no-cache]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Request-Id: [b6168343-dd9e-4a0f-9ec4-69a1de8f879a]
X-Runtime: ['0.080069']
content-length: ['117']
cache-control: [no-store]
content-length: ['126']
content-type: [application/json; charset=utf-8]
etag: [W/"d69940161df215958096efeb1a959d12"]
pragma: [no-cache]
transfer-encoding: [chunked]
vary: ['Accept-Encoding, Origin']
x-request-id: [a05d2bef-1d32-4857-97b5-6cc4136dfd29]
x-runtime: ['0.205660']
status: {code: 200, message: OK}
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_TOKEN]
Authorization: [!!python/unicode Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive]
User-Agent: [python-requests/2.18.4]
method: GET
uri: http://localhost:3000/api/v1/accounts/verify_credentials
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:
Cache-Control: ['max-age=0, private, must-revalidate']
Content-Type: [application/json; charset=utf-8]
ETag: [W/"622f72a29f8398775e2abff7cd51dbac"]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Frame-Options: [SAMEORIGIN]
X-Request-Id: [3852d894-50be-4342-a0e6-f9df2ddf5926]
X-Runtime: ['0.029510']
X-XSS-Protection: [1; mode=block]
content-length: ['650']
cache-control: ['max-age=0, private, must-revalidate']
content-length: ['669']
content-type: [application/json; charset=utf-8]
etag: [W/"05183e2c68a77cfb9877fc356465a322"]
transfer-encoding: [chunked]
vary: ['Accept-Encoding, Origin']
x-content-type-options: [nosniff]
x-frame-options: [SAMEORIGIN]
x-request-id: [0cdc8a2f-6deb-4437-bd96-4e7178e1b9cd]
x-runtime: ['0.230997']
x-xss-protection: [1; mode=block]
status: {code: 200, message: OK}
version: 1

Veure arxiu

@ -1,21 +1,28 @@
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
def api():
import mastodon
return mastodon.Mastodon(
api_base_url='http://localhost:3000',
client_id='__MASTODON_PY_TEST_ID',
client_secret='__MASTODON_PY_TEST_SECRET',
access_token='__MASTODON_PY_TEST_TOKEN')
return _api()
@pytest.fixture
def api2():
return _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN_2')
@pytest.fixture
def api_anonymous():
import mastodon
return mastodon.Mastodon(
api_base_url='http://localhost:3000',
client_id='__MASTODON_PY_TEST_ID',
client_secret='__MASTODON_PY_TEST_SECRET')
return _api(access_token=None)
@pytest.fixture()
def status(api):

Veure arxiu

@ -1,5 +1,43 @@
WITH new_app AS (
DELETE FROM oauth_access_tokens WHERE id = 6543210987654321;
DELETE FROM oauth_access_tokens WHERE id = 1234567890123456;
DELETE FROM oauth_applications WHERE id = 1234567890123456;
DELETE FROM users WHERE id = 1234567890123456;
DELETE FROM accounts WHERE id = 1234567890123456;
INSERT INTO accounts (
id,
username,
created_at,
updated_at
) VALUES (
1234567890123456,
'mastodonpy_test',
now(),
now()
);
INSERT INTO users (
id,
email,
account_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,
@ -10,28 +48,37 @@ WITH new_app AS (
created_at,
updated_at
) VALUES (
1234567890123456,
'Mastodon.py test suite',
'__MASTODON_PY_TEST_ID',
'__MASTODON_PY_TEST_SECRET',
'__MASTODON_PY_TEST_CLIENT_ID',
'__MASTODON_PY_TEST_CLIENT_SECRET',
'urn:ietf:wg:oauth:2.0:oob',
'read write follow',
'User',
1,
1234567890123456,
now(),
now()
)
RETURNING id
)
);
INSERT INTO oauth_access_tokens (
id,
token,
scopes,
application_id,
resource_owner_id,
created_at
) SELECT
'__MASTODON_PY_TEST_TOKEN',
) VALUES (
1234567890123456,
'__MASTODON_PY_TEST_ACCESS_TOKEN',
'read write follow',
new_app.id,
1234567890123456,
1234567890123456,
now()
), (
6543210987654321,
'__MASTODON_PY_TEST_ACCESS_TOKEN_2',
'read write follow',
1234567890123456,
1,
now()
FROM new_app;
);