public void CorrectRequestForCreate() {
            var factory = Substitute.For<IConnection>();
            var client = new KeysClient(factory);

            var body = new Models.Requests.Key { Name = "example" };
            client.Create(body);

            factory.Received().ExecuteRequest<Key>("account/keys", null, body, "ssh_key", Method.POST);
        }
        public void CorrectRequestForUpdateFingerprint() {
            var factory = Substitute.For<IConnection>();
            var client = new KeysClient(factory);

            var body = new Models.Requests.Key { Name = "example" };
            client.Update("fingerprint", body);

            var parameters = Arg.Is<List<Parameter>>(list => (string)list[0].Value == "fingerprint");
            factory.Received().ExecuteRequest<Key>("account/keys/{id}", parameters, body, "ssh_key", Method.PUT);
        }
        /// <summary>
        /// Update an existing key in your account
        /// </summary>
        public Task <Key> Update(object keyIdOrFingerprint, Models.Requests.Key key)
        {
            var parameters = new List <Parameter> {
                new Parameter {
                    Name = "id", Value = keyIdOrFingerprint, Type = ParameterType.UrlSegment
                }
            };

            return(_connection.ExecuteRequest <Key>("account/keys/{id}", parameters, key, "ssh_key", Method.PUT));
        }
Example #4
0
        public void CorrectRequestForCreate()
        {
            var factory = Substitute.For <IConnection>();
            var client  = new KeysClient(factory);

            var body = new Models.Requests.Key {
                Name = "example"
            };

            client.Create(body);

            factory.Received().ExecuteRequest <Key>("account/keys", null, body, "ssh_key", Method.POST);
        }
Example #5
0
        public void CorrectRequestForUpdateFingerprint()
        {
            var factory = Substitute.For <IConnection>();
            var client  = new KeysClient(factory);

            var body = new Models.Requests.Key {
                Name = "example"
            };

            client.Update("fingerprint", body);

            var parameters = Arg.Is <List <Parameter> >(list => (string)list[0].Value == "fingerprint");

            factory.Received().ExecuteRequest <Key>("account/keys/{id}", parameters, body, "ssh_key", Method.PUT);
        }
 /// <inheritdoc />
 /// <summary>
 /// Create a new key entry
 /// </summary>
 public Task <Key> Create(Models.Requests.Key key, CancellationToken token = default)
 {
     return(_connection.ExecuteRequest <Key>("account/keys", null, key, "ssh_key", Method.POST, token));
 }
Example #7
0
 /// <summary>
 /// Create a new key entry
 /// </summary>
 public Task<Key> Create(Models.Requests.Key key) {
     return _connection.ExecuteRequest<Key>("account/keys", null, key, "ssh_key", Method.POST);
 }