Skip to content

Commit 9f32b8a

Browse files
authored
Fixing auth integration tests for Python 3; Updating rules properly before running db tests. (#47)
1 parent e39ebc6 commit 9f32b8a

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

integration/test_auth.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
def _sign_in(custom_token, api_key):
25-
body = {'token' : custom_token, 'returnSecureToken' : True}
25+
body = {'token' : custom_token.decode(), 'returnSecureToken' : True}
2626
params = {'key' : api_key}
2727
resp = requests.request('post', _id_toolkit_url, params=params, json=body)
2828
resp.raise_for_status()

integration/test_db.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def update_rules():
2929
new_rules = json.load(rules_file)
3030
client = db.reference()._client
3131
rules = client.request('get', '/.settings/rules.json')
32-
existing = rules.get('rules', dict()).get('_adminsdk')
32+
existing = rules.get('rules')
3333
if existing != new_rules:
34-
rules['rules']['_adminsdk'] = new_rules
34+
rules['rules'] = new_rules
3535
client.request('put', '/.settings/rules.json', json=rules)
3636

3737
@pytest.fixture(scope='module')

tests/data/dinosaurs_index.json

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
{
2-
"python": {
3-
"dinodb": {
4-
"dinosaurs": {
5-
".indexOn": ["height", "ratings/pos"]
2+
"_adminsdk": {
3+
"python": {
4+
"dinodb": {
5+
"dinosaurs": {
6+
".indexOn": ["height", "ratings/pos"]
7+
},
8+
"scores": {
9+
".indexOn": ".value"
10+
}
611
},
7-
"scores": {
8-
".indexOn": ".value"
9-
}
10-
},
11-
"protected": {
12-
"$uid": {
13-
".read": "auth != null",
14-
".write": "$uid === auth.uid"
12+
"protected": {
13+
"$uid": {
14+
".read": "auth != null",
15+
".write": "$uid === auth.uid"
16+
}
17+
},
18+
"admin": {
19+
".read": "false",
20+
".write": "false"
21+
},
22+
"public": {
23+
".read": "true"
1524
}
16-
},
17-
"admin": {
18-
".read": "false",
19-
".write": "false"
20-
},
21-
"public": {
22-
".read": "true"
2325
}
2426
}
2527
}

0 commit comments

Comments
 (0)