Пример #1
0
        private static async Task <bool> executeSNS(string[] args, Credentials credentials)
        {
            var nArgs  = CLIHelper.GetNamedArguments(args);
            var helper = new SNSHelper();

            switch (args[1])
            {
            case "send":
            {
                return(true);
            }

            case "help":
            {
                HelpPrinter($"{args[0]}", "Simple Notificaiton Service",
                            ("send", "Accepts params: topic, data"));
                return(true);
            }

            default:
            {
                Console.WriteLine($"Try '{args[0]} help' to find out list of available commands.");
                throw new Exception($"Unknown SNS command: '{args[0]} {args[1]}'");
            }
            }
        }
        public void ListTopics_Should_ReturnTopics()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            SNSHelper helper = new SNSHelper(clientDetails);

            string[] topics = helper.ListTopics("");

            Assert.AreEqual(2, topics.Length);
        }
        public void TestUnSubscribe_Doesnt_Fail()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            SNSHelper helper = new SNSHelper(clientDetails);

            // TODO: Replace this with the valid subscription Arn
            const string subscriptionArn = "arn:aws:sns:us-east-1:167532394791:TestTopic:37be7a47-7e3f-418f-961e-2ef68af1749c";

            helper.Unsubscribe(subscriptionArn);
        }
        public void CreateTopicTwice_Should_Succeed_WithMatchingArns()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            SNSHelper helper = new SNSHelper(clientDetails);

            string topicArn  = helper.CreateTopic("TestTopic2");
            string topicArn2 = helper.CreateTopic("TestTopic2");

            Assert.AreEqual(topicArn, topicArn2, "Topic Arn's should match");
        }
        public void Publish_Should_PublishANotification()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            SNSHelper helper = new SNSHelper(clientDetails);

            const string topicArn = "arn:aws:sns:us-east-1:167532394791:TestTopic";

            string messageId = helper.Publish(topicArn, "Test", "This is a test of Publish...");

            Assert.IsNotEmpty(messageId);
        }
        public void CreateTopic_Should_CreateTopic()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            SNSHelper helper = new SNSHelper(clientDetails);

            string topicId = helper.CreateTopic("TestTopic");

            System.Diagnostics.Debug.WriteLine("Topic Id: " + topicId);

            Assert.IsNotEmpty(topicId);
        }
        public void TestSubscrive_Should_Subscribe()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            SNSHelper helper = new SNSHelper(clientDetails);

            const string topicArn = "arn:aws:sns:us-east-1:167532394791:TestTopic";
            const string protocol = "email";
            const string endpoint = "*****@*****.**";

            string subscriptionArn = helper.Subscribe(topicArn, protocol, endpoint);

            Assert.IsNotEmpty(subscriptionArn);
        }
        public void TestAddPermission_Sets_PermissionsOnTopic()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            SNSHelper helper   = new SNSHelper(clientDetails);
            string    topicArn = helper.CreateTopic("TestSetPermissionsTopic");

            // TODO: Replace this with a valid AWS account Id.
            string[]     awsAccountIds = new[] { "123456789012" };
            string[]     actionNames   = new[] { "*" };
            const string label         = "Test Topic Permissions";

            // There appears to be an issue with the AWS SDK 1.0.8.1 which failes validation
            // for action names and aws account ids whilst they are valid.
            helper.AddPermission(actionNames, awsAccountIds, label, topicArn);

            // Now clean up and delete the topic.
            helper.DeleteTopic(topicArn);
        }