コード例 #1
0
        public void TestAttributes()
        {
            using (var servlet = new ResponseTestServlet())
            {
                servlet.Response = ListObjectAttributesResponse;

                var config = new AmazonCloudDirectoryConfig {
                    ServiceURL = servlet.ServiceURL
                };
                using (var client = new AmazonCloudDirectoryClient(config))
                {
                    var response = client.ListObjectAttributes(new ListObjectAttributesRequest());

                    var attribute = response.Attributes.SingleOrDefault();
                    Assert.IsNotNull(attribute);

                    var key = attribute.Key;
                    Assert.IsNotNull(key);

                    Assert.AreEqual("Person", key.FacetName);
                    Assert.AreEqual("username", key.Name);
                    Assert.AreEqual("arn:aws:clouddirectory:us-east-1:123456789012:directory/AQPCHP0oaUPOoPHKMr1kMTs/schema/person/1", key.SchemaArn);

                    var value = attribute.Value;
                    Assert.IsNotNull(value);

                    Assert.IsNull(value.BinaryValue);
                    Assert.IsFalse(value.BooleanValue);
                    Assert.AreEqual(default(DateTime), value.DatetimeValue);
                    Assert.IsNull(value.NumberValue);
                    Assert.AreEqual("bob", value.StringValue);
                }
            }
        }
コード例 #2
0
        public void TestECSCredentials_LocalFullUri()
        {
            string uri        = "/ECS/Test/Endpoint/";
            string accessKey  = "SomeKey";
            string secretKey  = "SomeSecretKey";
            string token      = "Token";
            string expiration = DateTime.UtcNow.AddHours(1).ToString("s") + "Z";

            using (ResponseTestServlet servlet = new ResponseTestServlet(uri))
            {
                string server = "http://*****:*****@"{{
    ""AccessKeyId"" : ""{accessKey}"",
    ""SecretAccessKey"" : ""{secretKey}"",
    ""Token"" : ""{token}"",
    ""Expiration"" : ""{expiration}""
}}";

                ECSTaskCredentials generator = new ECSTaskCredentials();

                ImmutableCredentials credentials = generator.GetCredentials();

                Assert.AreEqual(accessKey, credentials.AccessKey);
                Assert.AreEqual(secretKey, credentials.SecretKey);
                Assert.AreEqual(token, credentials.Token);
            }

            System.Environment.SetEnvironmentVariable(ECSTaskCredentials.ContainerCredentialsFullURIEnvVariable, "");
        }
コード例 #3
0
        public void TestECSCredentialsLocal()
        {
            string uri        = "/ECS/Test/Endpoint/";
            string accessKey  = "SomeKey";
            string secretKey  = "SomeSecretKey";
            string token      = "Token";
            string expiration = DateTime.UtcNow.AddHours(1).ToString("s") + "Z";

            System.Environment.SetEnvironmentVariable(ECSTaskCredentials.ContainerCredentialsURIEnvVariable, uri);

            using (ResponseTestServlet servlet = new ResponseTestServlet(uri))
            {
                string server = "http://*****:*****@"{{
    ""AccessKeyId"" : ""{0}"",
    ""SecretAccessKey"" : ""{1}"",
    ""Token"" : ""{2}"",
    ""Expiration"" : ""{3}""
}}", accessKey, secretKey, token, expiration);

                ECSTaskCredentials generator = new ECSTaskCredentials();

                FieldInfo serverField = generator.GetType().GetField("Server", BindingFlags.Instance | BindingFlags.NonPublic);
                Assert.IsNotNull(serverField);
                serverField.SetValue(generator, server);

                ImmutableCredentials credentials = generator.GetCredentials();

                Assert.AreEqual(accessKey, credentials.AccessKey);
                Assert.AreEqual(secretKey, credentials.SecretKey);
                Assert.AreEqual(token, credentials.Token);
            }

            System.Environment.SetEnvironmentVariable(ECSTaskCredentials.ContainerCredentialsURIEnvVariable, "");
        }
コード例 #4
0
ファイル: CredentialsTests.cs プロジェクト: aws/aws-sdk-net
        public void TestECSCredentialsLocal()
        {

            string uri = "/ECS/Test/Endpoint/";
            string accessKey = "SomeKey";
            string secretKey = "SomeSecretKey";
            string token = "Token";
            string expiration = DateTime.UtcNow.AddHours(1).ToString("s") + "Z";

            System.Environment.SetEnvironmentVariable(ECSTaskCredentials.ContainerCredentialsURIEnvVariable, uri);

            using (ResponseTestServlet servlet = new ResponseTestServlet(uri))
            {
                string server = "http://*****:*****@"{{
    ""AccessKeyId"" : ""{0}"",
    ""SecretAccessKey"" : ""{1}"",
    ""Token"" : ""{2}"",
    ""Expiration"" : ""{3}""
}}", accessKey, secretKey, token, expiration);

                ECSTaskCredentials generator = new ECSTaskCredentials();

                FieldInfo serverField = generator.GetType().GetField("Server", BindingFlags.Instance | BindingFlags.NonPublic );
                Assert.IsNotNull(serverField);
                serverField.SetValue(generator, server);

                ImmutableCredentials credentials = generator.GetCredentials();

                Assert.AreEqual(accessKey, credentials.AccessKey);
                Assert.AreEqual(secretKey, credentials.SecretKey);
                Assert.AreEqual(token, credentials.Token);
            }

            System.Environment.SetEnvironmentVariable(ECSTaskCredentials.ContainerCredentialsURIEnvVariable, "");
        }