feat: the Tiny probe lists the account's users with their type and marks the integration's
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 3m28s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 58s
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 3m28s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 58s
Read-only. Tiny's API does what the user who connected the integration may do, so knowing which user that is, and its type, points at the permission. The name and e-mail come from the access token's claims; the token is never printed. It needs the app's Usuarios (Leitura) and a reconnect, and says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -584,6 +584,34 @@ class TinyProbeTests(FakeTinyCase):
|
||||
self.assertIn('77\t6\tRetirar pessoalmente', text)
|
||||
self.assertTrue(all(method == 'GET' for method, _ in self.calls))
|
||||
|
||||
def test_usuarios_lists_the_types_and_marks_the_integration_user(self):
|
||||
import base64 as b64
|
||||
handler = self.handler
|
||||
allowed = {'on': True}
|
||||
|
||||
def account(request):
|
||||
if request.url.path.endswith('/usuarios'):
|
||||
if not allowed['on']:
|
||||
return httpx.Response(403, text='')
|
||||
return httpx.Response(200, json={'itens': [
|
||||
{'id': 1, 'nome': 'Marcus', 'email': 'marcus@example.test', 'tipo': 'administrador'},
|
||||
{'id': 2, 'nome': 'Integração', 'email': 'dev@example.test', 'tipo': 'usuario'}]})
|
||||
return handler(request)
|
||||
self.tiny.http = httpx.Client(base_url=tiny_module.API, transport=httpx.MockTransport(account))
|
||||
claims = b64.urlsafe_b64encode(json.dumps({'name': 'Integração', 'email': 'dev@example.test'}).encode()).decode().rstrip('=')
|
||||
with mock.patch.object(self.tiny.auth, 'access_token', return_value=f'h.{claims}.s'):
|
||||
code, text = self.probe('usuarios')
|
||||
self.assertEqual(code, 0, text)
|
||||
self.assertIn('Integração conectada como: Integração · dev@example.test', text)
|
||||
self.assertIn('2\tusuario\tIntegração\tdev@example.test\t<- integração', text)
|
||||
self.assertIn('1\tadministrador\tMarcus\tmarcus@example.test', text)
|
||||
self.assertNotIn(claims, text)
|
||||
# Without the app's Usuários permission: says what to tick.
|
||||
allowed['on'] = False
|
||||
code, text = self.probe('usuarios')
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn('Marque Usuários (Leitura)', text)
|
||||
|
||||
def test_diagnostico_finds_the_part_tiny_refuses(self):
|
||||
handler = self.handler
|
||||
|
||||
|
||||
Reference in New Issue
Block a user