From 49f0bc7bd4e1d0ea0c52e38e005a613b6d2f7b75 Mon Sep 17 00:00:00 2001 From: Raja Nadar Date: Mon, 29 Aug 2016 18:01:05 -0700 Subject: [PATCH] add new sys/step-down api for hashicorp/vault#1146 --- src/VaultSharp/IVaultClient.cs | 11 +++++++++++ src/VaultSharp/VaultClient.cs | 7 +++++++ .../End2End/VaultClientEnd2EndTests.cs | 2 ++ 3 files changed, 20 insertions(+) diff --git a/src/VaultSharp/IVaultClient.cs b/src/VaultSharp/IVaultClient.cs index 6687fb29..edc5234b 100644 --- a/src/VaultSharp/IVaultClient.cs +++ b/src/VaultSharp/IVaultClient.cs @@ -371,6 +371,17 @@ public interface IVaultClient /// Task GetLeaderAsync(); + /// + /// Forces the node to give up active status. + /// If the node does not have active status, this endpoint does nothing. + /// Note that the node will sleep for ten seconds before attempting to grab the active lock again, + /// but if no standby nodes grab the active lock in the interim, + /// the same node may become the active node again. + /// This API is a root protected call. + /// + /// The task. + Task StepDownActiveNodeAsync(); + /// /// Gets information about the current encryption key used by Vault /// diff --git a/src/VaultSharp/VaultClient.cs b/src/VaultSharp/VaultClient.cs index cf90c80f..c57c775d 100644 --- a/src/VaultSharp/VaultClient.cs +++ b/src/VaultSharp/VaultClient.cs @@ -366,6 +366,13 @@ public async Task GetLeaderAsync() return leader; } + public async Task StepDownActiveNodeAsync() + { + await + MakeVaultApiRequest("sys/step-down", HttpMethod.Put) + .ConfigureAwait(_continueAsyncTasksOnCapturedContext); + } + public async Task GetEncryptionKeyStatusAsync() { var keyStatus = await MakeVaultApiRequest("sys/key-status", HttpMethod.Get).ConfigureAwait(continueOnCapturedContext: _continueAsyncTasksOnCapturedContext); diff --git a/test/VaultSharp.UnitTests/End2End/VaultClientEnd2EndTests.cs b/test/VaultSharp.UnitTests/End2End/VaultClientEnd2EndTests.cs index 90ea481e..319f8e50 100644 --- a/test/VaultSharp.UnitTests/End2End/VaultClientEnd2EndTests.cs +++ b/test/VaultSharp.UnitTests/End2End/VaultClientEnd2EndTests.cs @@ -41,6 +41,8 @@ public async Task AllTests() // await GithubAuthenticationProviderTests(); } + await _authenticatedClient.StepDownActiveNodeAsync(); + await EncryptStrongTests(); await MountedSecretBackendTests(); await MountedAuthenticationBackendTests();