def test_get_token_schema_legacy_internal_only(self):
     responses.add_callback(responses.POST,
                            'https://accounts.descarteslabs.com/token',
                            callback=token_response_callback)
     auth = Auth(token_info_path=None,
                 client_secret="client_secret",
                 client_id="ZOBAi4UROl5gKZIpxxlwOEfx8KpqXf2c")
     auth._get_token()
     self.assertEqual("id_token", auth._token)
    def test_get_token_legacy(self):
        responses.add(responses.POST,
                      'https://accounts.descarteslabs.com/token',
                      json=dict(id_token="id_token"),
                      status=200)
        auth = Auth(token_info_path=None,
                    client_secret="client_secret",
                    client_id="client_id")
        auth._get_token()

        self.assertEqual("id_token", auth._token)
    def test_get_token(self):
        responses.add(
            responses.POST,
            "https://accounts.descarteslabs.com/token",
            json=dict(access_token="access_token"),
            status=200,
        )
        auth = Auth(token_info_path=None,
                    client_secret="client_secret",
                    client_id="client_id")
        auth._get_token()

        assert "access_token" == auth._token
    def test_get_token_schema_internal_only(self):
        responses.add_callback(responses.POST,
                               'https://accounts.descarteslabs.com/token',
                               callback=token_response_callback)
        auth = Auth(token_info_path=None,
                    refresh_token="refresh_token",
                    client_id="client_id")
        auth._get_token()

        self.assertEqual("access_token", auth._token)

        auth = Auth(token_info_path=None,
                    client_secret="refresh_token",
                    client_id="client_id")
        auth._get_token()

        self.assertEqual("access_token", auth._token)