Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caducidad de token no se comprueba en operaciones de get #21

Open
fgalan opened this issue Jul 1, 2022 · 1 comment
Open

Caducidad de token no se comprueba en operaciones de get #21

fgalan opened this issue Jul 1, 2022 · 1 comment

Comments

@fgalan
Copy link
Contributor

fgalan commented Jul 1, 2022

Ahora mismo solo se implementa control de caducidad para el envio de lotes, i.e:

        res = self.__batch_creation_update(auth=auth, subservice = subservice, entities=entities)
        if res.status_code == 401:
            auth.get_auth_token_subservice(subservice = subservice)
            res = self.__batch_creation_update(auth=auth, subservice = subservice, entities=entities)

        if res.status_code != 204:
            raise Exception(f'Error in batch operation ({res.status_code}): {res.json()}')

Habría que implementarlo también para otras operacioens de la libreriá. A día de hoy los gets, pero cuando se implemente delete_entities (issue #14) también.

@fgalan
Copy link
Contributor Author

fgalan commented Jul 1, 2022

Por otra parte esta lógica no es del todo correcta:

        res = self.__batch_creation_update(auth=auth, subservice = subservice, entities=entities)
        if res.status_code == 401:
            auth.get_auth_token_subservice(subservice = subservice)
            res = self.__batch_creation_update(auth=auth, subservice = subservice, entities=entities)

        if res.status_code != 204:
            raise Exception(f'Error in batch operation ({res.status_code}): {res.json()}')

porque se asume en el caso res.status_code == 401 que no va haber fallos. Más correcto sería:

        res = self.__batch_creation_update(auth=auth, subservice = subservice, entities=entities)
        if res.status_code == 401:
            auth.get_auth_token_subservice(subservice = subservice)
            res = self.__batch_creation_update(auth=auth, subservice = subservice, entities=entities)
            if res.status_code != 204:
                raise Exception(f'Error in batch operation ({res.status_code}): {res.json()}')

        if res.status_code != 204:
            raise Exception(f'Error in batch operation ({res.status_code}): {res.json()}')

aunque muy bonito no es, por la repetición de cóigo... Seguro que se te ocurre algún refactor para que quede elegante ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant