Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rodolfomiranda committed Mar 29, 2024
1 parent 4ad8a93 commit b42309f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
27 changes: 15 additions & 12 deletions tests/app/test_aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def test_identifier_collection_end(helpers):
resend = aiding.IdentifierResourceEnd()
app.add_route("/identifiers", end)
app.add_route("/identifiers/{name}", resend)
app.add_route("/identifiers/{name}/events", resend)

groupEnd = aiding.GroupMemberCollectionEnd()
app.add_route("/identifiers/{name}/members", groupEnd)
Expand Down Expand Up @@ -365,7 +366,7 @@ def test_identifier_collection_end(helpers):
'salty': {'stem': 'signify:aid', 'pidx': 0, 'tier': 'low', 'sxlt': sxlt, 'transferable': True, 'kidx': 1,
'icodes': [MtrDex.Ed25519_Seed], 'ncodes': [MtrDex.Ed25519_Seed]}
}
res = client.simulate_put(path="/identifiers/aid1", body=json.dumps(body))
res = client.simulate_post(path="/identifiers/aid1/events", body=json.dumps(body))
assert res.status_code == 200

# Try with missing arguments
Expand Down Expand Up @@ -470,7 +471,7 @@ def test_identifier_collection_end(helpers):
'salty': {'stem': 'signify:aid', 'pidx': 0, 'tier': 'low', 'sxlt': sxlt, 'transferable': True, 'kidx': 3,
'icodes': [MtrDex.Ed25519_Seed], 'ncodes': [MtrDex.Ed25519_Seed]}
}
res = client.simulate_put(path="/identifiers/aid3", body=json.dumps(body))
res = client.simulate_post(path="/identifiers/aid3/events", body=json.dumps(body))
assert res.status_code == 200

# create member habs for group AID
Expand Down Expand Up @@ -654,6 +655,7 @@ def test_identifier_collection_end(helpers):
resend = aiding.IdentifierResourceEnd()
app.add_route("/identifiers", end)
app.add_route("/identifiers/{name}", resend)
app.add_route("/identifiers/{name}/events", resend)
eventsEnd = agenting.KeyEventCollectionEnd()
app.add_route("/events", eventsEnd)

Expand Down Expand Up @@ -722,7 +724,7 @@ def test_identifier_collection_end(helpers):
"transferable": True,
}
}
res = client.simulate_put(path="/identifiers/randy1", body=json.dumps(body))
res = client.simulate_post(path="/identifiers/randy1/events", body=json.dumps(body))
assert res.status_code == 200
assert res.json["response"] == serder.ked
res = client.simulate_get(path="/identifiers")
Expand All @@ -740,7 +742,7 @@ def test_identifier_collection_end(helpers):
body = {'ixn': serder.ked,
'sigs': sigers
}
res = client.simulate_put(path="/identifiers/randy1?type=ixn", body=json.dumps(body))
res = client.simulate_post(path="/identifiers/randy1/events", body=json.dumps(body))
assert res.status_code == 200
assert res.json["response"] == serder.ked

Expand All @@ -751,17 +753,17 @@ def test_identifier_collection_end(helpers):
assert events[2] == serder.ked

# Bad interactions
res = client.simulate_put(path="/identifiers/badrandy?type=ixn", body=json.dumps(body))
res = client.simulate_post(path="/identifiers/badrandy/events", body=json.dumps(body))
assert res.status_code == 404
assert res.json == {'title': 'No AID badrandy found'}

body = {'sigs': sigers}
res = client.simulate_put(path="/identifiers/randy1?type=ixn", body=json.dumps(body))
res = client.simulate_post(path="/identifiers/randy1/events", body=json.dumps(body))
assert res.status_code == 400
assert res.json == {'description': "required field 'ixn' missing from request", 'title': 'invalid interaction'}
assert res.json == {'description': "required field 'rot' or 'ixn' missing from request", 'title': 'invalid request'}

body = {'ixn': serder.ked}
res = client.simulate_put(path="/identifiers/randy1?type=ixn", body=json.dumps(body))
res = client.simulate_post(path="/identifiers/randy1/events", body=json.dumps(body))
assert res.status_code == 400
assert res.json == {'description': "required field 'sigs' missing from request", 'title': 'invalid interaction'}

Expand All @@ -774,7 +776,7 @@ def test_identifier_collection_end(helpers):
"transferable": True,
}
}
res = client.simulate_put(path="/identifiers/randybad?type=rot", body=json.dumps(body))
res = client.simulate_post(path="/identifiers/randybad/events", body=json.dumps(body))
assert res.status_code == 404
assert res.json == {'title': 'No AID with name randybad found'}

Expand All @@ -786,9 +788,9 @@ def test_identifier_collection_end(helpers):
"transferable": True,
}
}
res = client.simulate_put(path="/identifiers/randy1", body=json.dumps(body))
res = client.simulate_post(path="/identifiers/randy1/events", body=json.dumps(body))
assert res.status_code == 400
assert res.json == {'description': "required field 'rot' missing from request", 'title': 'invalid rotation'}
assert res.json == {'description': "required field 'rot' or 'ixn' missing from request", 'title': 'invalid request'}

# rotate to unknown witness
serder = eventing.rotate(keys=keys,
Expand All @@ -812,7 +814,7 @@ def test_identifier_collection_end(helpers):
"transferable": True,
}
}
res = client.simulate_put(path="/identifiers/randy1", body=json.dumps(body))
res = client.simulate_post(path="/identifiers/randy1/events", body=json.dumps(body))
assert res.status_code == 400
assert res.json == {'description': "unknown witness EJJR2nmwyYAZAoTNZH3ULvaU6Z-i0d8fSVPzhzS6b5CM",
'title': '400 Bad Request'}
Expand All @@ -823,6 +825,7 @@ def test_identifier_collection_end(helpers):
resend = aiding.IdentifierResourceEnd()
app.add_route("/identifiers", end)
app.add_route("/identifiers/{name}", resend)
app.add_route("/identifiers/{name}/events", resend)
eventsEnd = agenting.KeyEventCollectionEnd()
app.add_route("/events", eventsEnd)

Expand Down
Loading

0 comments on commit b42309f

Please sign in to comment.