|
| 1 | +# Copyright 2019-2025 Flavio Garcia |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +from automatoes.crypto import generate_rsa_key |
| 16 | +from automatoes.model import Account |
| 17 | +from cartola import security |
| 18 | +from tests import get_protocol, get_transport, PEEBLE_URL |
| 19 | +from tornado import testing |
| 20 | + |
| 21 | + |
| 22 | +class AccountTestCase(testing.AsyncTestCase): |
| 23 | + """ Test letsencrypt nonce |
| 24 | + """ |
| 25 | + |
| 26 | + @testing.gen_test |
| 27 | + async def test_new_acount(self): |
| 28 | + protocol = get_protocol(get_transport()) |
| 29 | + contact = "candango_{}_{}@candango.org".format( |
| 30 | + security.random_string(5, False, False), |
| 31 | + security.random_string(5, False, False) |
| 32 | + ) |
| 33 | + # To check against the get_registration method after |
| 34 | + # TODO: check against more than one emails in the contacts |
| 35 | + peeble_term = ("data:text/plain,Do%20what%20thou%20wilt") |
| 36 | + account = Account(key=generate_rsa_key(4096)) |
| 37 | + response = protocol.new_account(account, [contact], True) |
| 38 | + self.assertEqual(peeble_term, response.terms) |
| 39 | + self.assertEqual("valid", response.contents['status']) |
| 40 | + account.uri = response.uri |
| 41 | + self.assertEqual(PEEBLE_URL, "/".join(response.uri.split("/")[0:3])) |
| 42 | + self.assertEqual("my-account", "/".join(response.uri.split("/")[3:4])) |
| 43 | + self.assertIsInstance(response.uri.split("/")[4:5][0], str) |
| 44 | + protocol.get_registration(account) |
0 commit comments