$:.push File.expand_path("../../lib", __FILE__) require 'helix_web_services_client' require_relative './util/test_config' require_relative './util/string_utils' require 'pp' api = api_as_jdoe rand = random_string client_id = "test-client-#{random_string}" client_command = HelixWebServices::ClientCommand.new( client: client_id, host: nil, # TODO this seems like a bug, not sure how to fix quickly altRoots: ['/alt/1', '/alt/2'] ) api.server_clients_post('localhost', client_command) all_clients = api.server_clients_get('localhost') unless all_clients.any? { |b| b.client == client_id } raise "Did not locate client #{client_id}" end saved_client = api.server_clients_client_get('localhost', client_id) raise 'alt_roots are incorrect' unless saved_client.alt_roots == client_command.alt_roots to_update = HelixWebServices::ClientCommand.new( description: "Update #{rand}" ) api.server_clients_client_patch('localhost', client_id, to_update) updated = api.server_clients_client_get('localhost', client_id) raise 'client not updated' if updated.description.strip != to_update.description.strip api.server_clients_client_delete('localhost', client_id) all_clients2 = api.server_clients_get('localhost') if all_clients2.any? { |b| b.client == client_id } raise "Did not delete client #{client_id}" end