Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Reworked config check scripts to work with pytest #9

Merged
merged 1 commit into from Feb 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 57 additions & 0 deletions config-test/test_webextensions_stack.py
@@ -0,0 +1,57 @@
import configparser
import pytest
from fxa.__main__ import DEFAULT_CLIENT_ID
from fxa.plugins.requests import FxABearerTokenAuth
from kinto_http import Client


@pytest.fixture
def conf():
config = configparser.ConfigParser()
config.read('manifest.ini')
return config


def test_add_content(env, conf):
# Grab a bearer token that we can use to talk to the webextensions endpoint
email = conf.get(env, 'fxa_user_email')
passwd = conf.get(env, 'fxa_user_password')
auth = FxABearerTokenAuth(
email,
passwd,
scopes=['sync:addon_storage'],
client_id=DEFAULT_CLIENT_ID,
account_server_url=conf.get(env, 'account_server_url'),
oauth_server_url=conf.get(env, 'oauth_server_url'),
)
client = Client(
server_url=conf.get(env, 'we_server_url'),
auth=auth
)

# First, we need to have one more more collections
collections = client.get_collections('default')
assert len(collections) > 0

# Add a record to our QA collection and make sure we have N+1 records
existing_records = client.get_records(conf.get(env, 'qa_collection'), 'default')
assert len(existing_records) > 0
data = {"payload": {"encrypted": "SmluZ28gdGVzdA=="}}
resp = client.create_record(
data,
collection=conf.get(env, 'qa_collection'),
bucket='default',
)
new_record_id = resp['data']['id']
updated_records = client.get_records(conf.get(env, 'qa_collection'), 'default')
assert len(updated_records) == len(existing_records) + 1

client.delete_record(
new_record_id,
collection=conf.get(env, 'qa_collection'),
bucket='default'
)
updated_records = client.get_records(conf.get(env, 'qa_collection'), 'default')
assert len(updated_records) == len(existing_records)


14 changes: 13 additions & 1 deletion manifest.ini
@@ -1,6 +1,18 @@
[stage]
server = https://kinto.stage.mozaws.net/v1
writer_server = https://kinto-writer.stage.mozaws.net/v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does prod have a writer_server?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prod does have one but QA does not have access to it --- the staging value is used for our stage-deployment testing

we_server_url = https://webextensions-settings.stage.mozaws.net/v1
account_server_url = https://api.accounts.firefox.com/v1
oauth_server_url = https://oauth.accounts.firefox.com/v1
fxa_user_email =
fxa_user_password =
qa_collection = 3e0f013d2362aa4fa7b0db2fefb40011b9545d78dcca7aabc0d32f0b42f1733d

[prod]
server = https://firefox.settings.services.mozilla.com/v1/
server = https://firefox.settings.services.mozilla.com/v1/
we_server_url = https://webextensions.settings.services.mozilla.com/v1
account_server_url = https://api.accounts.firefox.com/v1
oauth_server_url = https://oauth.accounts.firefox.com/v1
fxa_user_email =
fxa_user_password =
qa_collection = 3e0f013d2362aa4fa7b0db2fefb40011b9545d78dcca7aabc0d32f0b42f1733d
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the qa_collection uuid to be the same between stage and prod, or do we care?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't care because we just need something unique that Firefox will not attempt to read and use