Beispiel #1
0
        private async Task GithubAuthenticationProviderTests()
        {
            // github auth

            var personalAccessToken = "2ba5fecdddbf09b2b6facc495bdae12f3067d9d4";
            var path         = "github" + Guid.NewGuid();
            var prefix       = "auth/" + path;
            var organization = "testingalib";
            var team         = "testalibteam1";

            var githubAuthenticationInfo = new GitHubAuthenticationInfo(path, personalAccessToken);

            var githubClient      = VaultClientFactory.CreateVaultClient(_vaultUri, githubAuthenticationInfo);
            var githubAuthBackend = new AuthenticationBackend {
                BackendType = AuthenticationBackendType.GitHub, AuthenticationPath = githubAuthenticationInfo.MountPoint
            };

            await _authenticatedVaultClient.EnableAuthenticationBackendAsync(githubAuthBackend);

            await _authenticatedVaultClient.WriteSecretAsync(prefix + "/config", new Dictionary <string, object> {
                { "organization", organization }
            });

            await _authenticatedVaultClient.WriteSecretAsync(prefix + "/map/teams/" + team, new Dictionary <string, object> {
                { "value", "root" }
            });

            var authBackends = await githubClient.GetAllEnabledAuthenticationBackendsAsync();

            Assert.True(authBackends.Data.Any());

            await _authenticatedVaultClient.DisableAuthenticationBackendAsync(githubAuthBackend.AuthenticationPath);
        }