def setUp(self):
     """
     Initializes a BasicAuthorizer for testing
     """
     super(BasicAuthorizerTests, self).setUp()
     self.username = "******"
     self.password = "******"
     self.authorizer = BasicAuthorizer(self.username, self.password)
def test_unicode_handling(username, password):
    """
    With a unicode string for the password, set and verify the
    Authorization header.
    """
    authorizer = BasicAuthorizer(username, password)
    header_val = authorizer.get_authorization_header()

    assert header_val[:6] == "Basic "
    decoded = base64.b64decode(header_val[6:].encode("utf-8")).decode("utf-8")
    assert decoded == f"{username}:{password}"
 def __init__(self, client_id: str, client_secret: str, **kwargs: Any):
     if "authorizer" in kwargs:
         log.error("ArgumentError(ConfidentialAppClient.authorizer)")
         raise exc.GlobusSDKUsageError(
             "Cannot give a ConfidentialAppAuthClient an authorizer")
     super().__init__(
         client_id=client_id,
         authorizer=BasicAuthorizer(client_id, client_secret),
         **kwargs,
     )
     log.info(f"Finished initializing client, client_id={client_id}")
    def __init__(self, client_id, client_secret, **kwargs):
        if "authorizer" in kwargs:
            logger.error('ArgumentError(ConfidentialAppClient.authorizer)')
            raise GlobusSDKUsageError(
                "Cannot give a ConfidentialAppAuthClient an authorizer")

        AuthClient.__init__(
            self, client_id=client_id,
            authorizer=BasicAuthorizer(client_id, client_secret),
            **kwargs)
        self.logger.info('Finished initializing client, client_id={}'
                         .format(client_id))
 def test_unicode_handling(self, username, password):
     """
     With a unicode string for the password, set and verify the
     Authorization header.
     """
     header_dict = {}
     authorizer = BasicAuthorizer(username, password)
     authorizer.set_authorization_header(header_dict)
     # confirm value
     self.assertEqual(header_dict["Authorization"][:6], "Basic ")
     decoded = base64.b64decode(six.b(
         header_dict["Authorization"][6:])).decode('utf-8')
     self.assertEqual(decoded, u"{0}:{1}".format(username, password))
Exemple #6
0
def test_unicode_handling(username, password):
    """
    With a unicode string for the password, set and verify the
    Authorization header.
    """
    header_dict = {}
    authorizer = BasicAuthorizer(username, password)
    authorizer.set_authorization_header(header_dict)

    assert header_dict["Authorization"][:6] == "Basic "
    decoded = base64.b64decode(six.b(
        header_dict["Authorization"][6:])).decode("utf-8")
    assert decoded == u"{}:{}".format(username, password)
Exemple #7
0
def authorizer():
    return BasicAuthorizer(USERNAME, PASSWORD)