public void ConjurClientE2ETest() { // Set environment variables for Conjur // export CONJUR_APPLIANCE_URL=https://conjur-master // export CONJUR_ACCOUNT=conjur // export CONJUR_AUTHN_LOGON=host/myApp // export CONJUR_AUTHN_API_KEY=35a9ej72v0q8ek25fghn52g1rjvm29qwxv738ts71j2d5hdwk1s34fbn Environment.SetEnvironmentVariable("CONJUR_APPLIANCE_URL", "https://conjur-master"); Environment.SetEnvironmentVariable("CONJUR_ACCOUNT", "conjur"); Environment.SetEnvironmentVariable("CONJUR_AUTHN_LOGIN", "admin"); Environment.SetEnvironmentVariable("CONJUR_AUTHN_API_KEY", "35a9ej72v0q8ek25fghn52g1rjvm29qwxv738ts71j2d5hdwk1s34fbn"); Environment.SetEnvironmentVariable("CONJUR_IGNORE_UNTRUSTED_SSL", "yes"); Conjur conjur = new Conjur(); // retrieve all the Conjur resources this application has access to List <Resource> resources = conjur.ListResources(); foreach (Resource r in resources) { Console.WriteLine("Printing out all variable resources"); if (r.Kind == ResourceKind.variable) { SecureString value = conjur.RetrieveSecret(r.Id); Console.WriteLine("{0} value is {1}", r.Id, Utilities.ToString(value)); } } }
public void TestConjurAppendPolicyInvalidPolicyBranch() { Conjur conjur = new Conjur(TestConfig.ValidConfig); conjur.Authenticate(); conjur.AppendPolicy("INVALID", TestConfig.ValidPolicyContent); }
public void TestValidConjurAuthenticate() { var config = new Configuration(TestConfig.ApplianceUrl, TestConfig.AuthnUrl, TestConfig.Account, TestConfig.Username, TestConfig.ApiKey, true); Conjur conjur = new Conjur(config); conjur.Authenticate(); }
public void TestConjurAppendPolicyValid() { Conjur conjur = new Conjur(TestConfig.ValidConfig); conjur.Authenticate(); conjur.AppendPolicy(TestConfig.ValidPolicyId, TestConfig.ValidPolicyContent); }
public void TestInvalidConjurRetrieveSecret() { var config = new Configuration(TestConfig.ApplianceUrl, null, TestConfig.Account, TestConfig.Username, TestConfig.ApiKey, true); Conjur conjur = new Conjur(config); conjur.Authenticate(); conjur.RetrieveSecret("path/to/secret/not/real"); }
public void TestInvalidConjurAuthenticate() { var invalidApiKey = Utilities.ToSecureString("invalidApiKey"); var config = new Configuration(TestConfig.ApplianceUrl, TestConfig.AuthnUrl, TestConfig.Account, TestConfig.Username, invalidApiKey, true); Conjur conjur = new Conjur(config); conjur.Authenticate(); }
public void TestConjurAppendPolicyInvalidPolicyContent() { // 422 is returned when invalid policy Conjur conjur = new Conjur(TestConfig.ValidConfig); conjur.Authenticate(); conjur.AppendPolicy(TestConfig.ValidPolicyId, "notValidYaml"); }
public void TestConjurListResourcesValid() { var config = new Configuration(TestConfig.ApplianceUrl, null, TestConfig.Account, TestConfig.Username, TestConfig.ApiKey, true); Conjur conjur = new Conjur(config); conjur.Authenticate(); conjur.ListResources(); }
public void TestInvalidConjurRetrieveSecretApiKey() { var invalidApiKey = Utilities.ToSecureString("invalidApiKey"); var config = new Configuration(TestConfig.ApplianceUrl, null, TestConfig.Account, TestConfig.Username, invalidApiKey, true); Conjur conjur = new Conjur(config); conjur.Authenticate(); conjur.RetrieveSecret("path/to/secret"); }
public void TestValidConjurHealth() { var config = new Configuration(TestConfig.ApplianceUrl, TestConfig.AuthnUrl, TestConfig.Account, TestConfig.Username, TestConfig.ApiKey, true); Conjur conjur = new Conjur(config); JObject health = conjur.GetHealth(); string uiService = health.SelectToken(".services.ui").ToString(); Assert.AreEqual(uiService, "ok"); }
public void TestValidConjurInfo() { var config = new Configuration(TestConfig.ApplianceUrl, TestConfig.AuthnUrl, TestConfig.Account, TestConfig.Username, TestConfig.ApiKey, true); Conjur conjur = new Conjur(config); JObject info = conjur.GetInfo(); string conjurAccount = info.SelectToken(".configuration.conjur.account").ToString(); Assert.AreEqual(TestConfig.Account, conjurAccount); }
public void TestConjurAddSecretInvalidVariableId() { var config = new Configuration(TestConfig.ApplianceUrl, null, TestConfig.Account, TestConfig.Username, TestConfig.ApiKey, true); Conjur conjur = new Conjur(config); conjur.Authenticate(); string secretPath = "add/value/of/secret/invalid"; conjur.AddSecret(secretPath, Utilities.ToSecureString("newSecret")); }
public void TestConjurAddSecretInvalidSecretValue() { // return 422 when empty secret value var config = new Configuration(TestConfig.ApplianceUrl, null, TestConfig.Account, TestConfig.Username, TestConfig.ApiKey, true); Conjur conjur = new Conjur(config); conjur.Authenticate(); string secretPath = "add/value/of/secret"; conjur.AddSecret(secretPath, Utilities.ToSecureString("")); }
public static void Main(string[] args) { Conjur conjur = new Conjur(); // Authenticate the conjur client conjur.Authenticate(); // Retrieve a specific secret SecureString secretValue = conjur.RetrieveSecret("cicd-secrets/prod-db-username"); Console.WriteLine("Secret Value: {0}", Utilities.ToString(secretValue)); }
public void TestConjurAddSecretValid() { var config = new Configuration(TestConfig.ApplianceUrl, null, TestConfig.Account, TestConfig.Username, TestConfig.ApiKey, true); Conjur conjur = new Conjur(config); conjur.Authenticate(); string secretPath = "add/value/of/secret"; conjur.AddSecret(secretPath, Utilities.ToSecureString("newSecret")); SecureString secretValue = conjur.RetrieveSecret(secretPath); Assert.AreEqual(Utilities.ToString(secretValue), "newSecret"); }