Exemplo n.º 1
0
    def test_valid_customer(self):
        """test a customer who should authenticate successfully"""
        request = MockRequest()

        key_list = list_customer_keys(self._connection, _test_username)
        self.assertEqual(len(key_list), 1)
        key_id, key_value = key_list[0]

        authentication_string = compute_authentication_string(
            key_id,
            key_value,
            _test_username,
            _test_method,
            current_timestamp(),
            _test_uri
        )
        request.__dict__["authorization"] = authentication_string.split()
        request.__dict__["method"] = _test_method
        request.__dict__["headers"] = {
            'x-nimbus-io-timestamp' : str(current_timestamp())
        } 
        request.__dict__["path_qs"] = _test_uri

        authenticator = SqlAuthenticator()
        authenticated = authenticator.authenticate(
            self._connection, _test_username, request
        )
        self.assertTrue(authenticated)
Exemplo n.º 2
0
def _handle_create_customer(connection, options):
    create_customer(connection, options.username, options.versioning)
    add_key_to_customer(connection, options.username)
    key_id, key = list_customer_keys(connection, options.username)[0]
    sys.stdout.write("Username {0}\n".format(options.username))
    sys.stdout.write("AuthKeyId {0}\n".format(key_id))
    sys.stdout.write("AuthKey {0}\n".format(key))
    sys.stdout.write("\n")
Exemplo n.º 3
0
def _handle_create_customer(connection, options):
    create_customer(connection, options.username, options.versioning)
    add_key_to_customer(connection, options.username)
    key_id, key = list_customer_keys(connection, options.username)[0]
    sys.stdout.write("Username {0}\n".format(options.username))
    sys.stdout.write("AuthKeyId {0}\n".format(key_id))
    sys.stdout.write("AuthKey {0}\n".format(key))
    sys.stdout.write("\n")
Exemplo n.º 4
0
def _handle_create_customer(connection, options):
    create_customer(connection, options.username, options.versioning)
    add_key_to_customer(connection, options.username)
    key_id, key = list_customer_keys(connection, options.username)[0]
    print "Username",  options.username
    print "AuthKeyId",  str(key_id)
    print "AuthKey", key
    print
Exemplo n.º 5
0
    def test_valid_customer(self):
        """test a customer who should authenticate successfully"""
        request = MockRequest()

        key_list = list_customer_keys(self._connection, _test_username)
        self.assertEqual(len(key_list), 1)
        key_id, key_value = key_list[0]

        authentication_string = compute_authentication_string(
            key_id, key_value, _test_username, _test_method,
            current_timestamp(), _test_uri)
        request.__dict__["authorization"] = authentication_string.split()
        request.__dict__["method"] = _test_method
        request.__dict__["headers"] = {
            'x-nimbus-io-timestamp': str(current_timestamp())
        }
        request.__dict__["path_qs"] = _test_uri

        authenticator = SqlAuthenticator()
        authenticated = authenticator.authenticate(self._connection,
                                                   _test_username, request)
        self.assertTrue(authenticated)
Exemplo n.º 6
0
def _handle_list_keys(connection, options):
    sys.stderr.write("listing customer keys {0}\n".format(options.username))
    for key_id, key in list_customer_keys(connection, options.username):
        sys.stderr.write("{0:6} {1}\n".format(key_id, key))
    sys.stderr.write("listed\n")
Exemplo n.º 7
0
def _handle_list_keys(connection, options):
    sys.stderr.write("listing customer keys {0}\n".format(options.username))
    for key_id, key in list_customer_keys(connection, options.username):
        sys.stderr.write("{0:6} {1}\n".format(key_id, key))
    sys.stderr.write("listed\n")
Exemplo n.º 8
0
def _handle_list_keys(connection, options):
    print >> sys.stderr, "listing customer keys", options.username
    for key_id, key in list_customer_keys(connection, options.username):
        print >> sys.stderr, "%6d" % key_id, key
    print >> sys.stderr, "listed"