Example #1
0
 def notify(self):
     print "{0}".format(self.notify_string)
     if self.sns_topic and self.sns_region:
         print "Notifying SNS topic: {0}".format(self.sns_topic)
         boto.connect_sns()
         sns = boto.sns.connect_to_region(self.sns_region)
         sns.publish(self.sns_topic, self.notify_string)
Example #2
0
    def remove_device(self, device):
        boto.connect_sns(aws_access_key_id=self.aws_access_key_id,
                         aws_secret_access_key=self.aws_secret_access_key)

        sns_conn = boto.sns.connect_to_region(
            region_name=self.aws_sns_region,
            aws_access_key_id=self.aws_access_key_id,
            aws_secret_access_key=self.aws_secret_access_key)
        sns_conn.delete_endpoint(device.aws_sns_arn)
Example #3
0
    def remove_device(self, device):
        boto.connect_sns(
            aws_access_key_id=self.aws_access_key_id,
            aws_secret_access_key=self.aws_secret_access_key)

        sns_conn = boto.sns.connect_to_region(
            region_name=self.aws_sns_region,
            aws_access_key_id=self.aws_access_key_id,
            aws_secret_access_key=self.aws_secret_access_key)
        sns_conn.delete_endpoint(device.aws_sns_arn)
Example #4
0
    def send_notification_to_device(self, device, message, message_format):
        payload = json.dumps({"GCM": json.dumps({"data": message})})

        boto.connect_sns(aws_access_key_id=self.aws_access_key_id,
                         aws_secret_access_key=self.aws_secret_access_key)

        sns_conn = boto.sns.connect_to_region(
            region_name=self.aws_sns_region,
            aws_access_key_id=self.aws_access_key_id,
            aws_secret_access_key=self.aws_secret_access_key)
        sns_conn.publish(target_arn=device.aws_sns_arn,
                         message=payload,
                         message_structure=message_format)
Example #5
0
    def send_notification_to_device(self, device, message, message_format):
        payload = json.dumps({"GCM": json.dumps({"data": message})})

        boto.connect_sns(
            aws_access_key_id=self.aws_access_key_id,
            aws_secret_access_key=self.aws_secret_access_key)

        sns_conn = boto.sns.connect_to_region(
            region_name=self.aws_sns_region,
            aws_access_key_id=self.aws_access_key_id,
            aws_secret_access_key=self.aws_secret_access_key)
        sns_conn.publish(
            target_arn=device.aws_sns_arn,
            message=payload,
            message_structure=message_format)
Example #6
0
def main():
	sns=boto.connect_sns();
	raw_input("Going to create the alpha and beta topics. Enter to continue");
	sns.create_topic("Alpha1");
	sns.create_topic("Beta1");
	raw_input("Alpha and Beta topics made. Here is the list of topics.");
	dic=sns.get_all_topics()['ListTopicsResponse']['ListTopicsResult']['Topics'];
	print dic;
	showTopics(dic);
	delete=raw_input("I am now going to delete the Beta topic. Copy beta and enter it here: ");
	sns.delete_topic(delete);
	arn=raw_input("Beta was deleted here is the new list of topics.");
	dic=sns.get_all_topics()['ListTopicsResponse']['ListTopicsResult']['Topics'];
	showTopics(dic);
	arn=raw_input("We are now going to subscribe to the alpha topic. Copy and paste alpha here: ");
	sns.subscribe(arn, "email", "*****@*****.**");
	print arn;
	sns.subscribe(arn, "email-json", "*****@*****.**");
	sns.subscribe(arn, "http", "http://cloud.comtor.org/csc470logger/logger");
	raw_input("There should now be 3 subscriptions added to the topic. Go check in console if needed. \nHere are the detials");
	printinfo(arn)
	raw_input("I am now going to change the display name for the topic.");
	sns.set_topic_attributes(arn,"DisplayName", "NewName");
	raw_input("Name change made. The new information is... ");
	printinfo(arn)
	raw_input("I am now going to send a message to all of those who have subscribed.");
	print sns.publish(arn, "Hello classmates. What is int?");
	raw_input("Message sent. Please check mail.");
	raw_input("We are now going to make a cloud watch alarm.");
	cw=boto.connect_cloudwatch()
	myMetric=cw.list_metrics()[0]
	print cw.describe_alarms()[0]
	cw.create_alarm(cw.describe_alarms()[0])
Example #7
0
def test_publish_to_http():
    httpretty.HTTPretty.register_uri(
        method="POST",
        uri="http://example.com/foobar",
    )

    conn = boto.connect_sns()
    conn.create_topic("some-topic")
    topics_json = conn.get_all_topics()
    topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']

    conn.subscribe(topic_arn, "http", "http://example.com/foobar")

    response = conn.publish(topic=topic_arn, message="my message", subject="my subject")
    message_id = response['PublishResponse']['PublishResult']['MessageId']

    last_request = httpretty.last_request()
    last_request.method.should.equal("POST")
    parse_qs(last_request.body.decode('utf-8')).should.equal({
        "Type": ["Notification"],
        "MessageId": [message_id],
        "TopicArn": ["arn:aws:sns:us-east-1:123456789012:some-topic"],
        "Subject": ["my subject"],
        "Message": ["my message"],
        "Timestamp": ["2013-01-01T00:00:00.000Z"],
        "SignatureVersion": ["1"],
        "Signature": ["EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc="],
        "SigningCertURL": ["https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem"],
        "UnsubscribeURL": ["https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:123456789012:some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"],
    })
Example #8
0
def test_topic_attributes():
    conn = boto.connect_sns()
    conn.create_topic("some-topic")

    topics_json = conn.get_all_topics()
    topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']

    attributes = conn.get_topic_attributes(topic_arn)['GetTopicAttributesResponse']['GetTopicAttributesResult']['Attributes']
    attributes["TopicArn"].should.equal("arn:aws:sns:us-east-1:123456789012:some-topic")
    attributes["Owner"].should.equal(123456789012)
    attributes["Policy"].should.equal(DEFAULT_TOPIC_POLICY)
    attributes["DisplayName"].should.equal("")
    attributes["SubscriptionsPending"].should.equal(0)
    attributes["SubscriptionsConfirmed"].should.equal(0)
    attributes["SubscriptionsDeleted"].should.equal(0)
    attributes["DeliveryPolicy"].should.equal("")
    attributes["EffectiveDeliveryPolicy"].should.equal(DEFAULT_EFFECTIVE_DELIVERY_POLICY)

    conn.set_topic_attributes(topic_arn, "Policy", {"foo": "bar"})
    conn.set_topic_attributes(topic_arn, "DisplayName", "My display name")
    conn.set_topic_attributes(topic_arn, "DeliveryPolicy", {"http": {"defaultHealthyRetryPolicy": {"numRetries": 5}}})

    attributes = conn.get_topic_attributes(topic_arn)['GetTopicAttributesResponse']['GetTopicAttributesResult']['Attributes']
    attributes["Policy"].should.equal("{'foo': 'bar'}")
    attributes["DisplayName"].should.equal("My display name")
    attributes["DeliveryPolicy"].should.equal("{'http': {'defaultHealthyRetryPolicy': {'numRetries': 5}}}")
Example #9
0
def test_get_endpoint_attributes():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(
        name="my-application",
        platform="APNS",
    )
    application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']

    endpoint = conn.create_platform_endpoint(
        platform_application_arn=application_arn,
        token="some_unique_id",
        custom_user_data="some user data",
        attributes={
            "Enabled": False,
            "CustomUserData": "some data",
        },
    )
    endpoint_arn = endpoint['CreatePlatformEndpointResponse']['CreatePlatformEndpointResult']['EndpointArn']

    attributes = conn.get_endpoint_attributes(endpoint_arn)['GetEndpointAttributesResponse']['GetEndpointAttributesResult']['Attributes']
    attributes.should.equal({
        "Token": "some_unique_id",
        "Enabled": 'False',
        "CustomUserData": "some data",
    })
Example #10
0
def test_creating_subscription():
    conn = boto.connect_sns()
    conn.create_topic("some-topic")
    topics_json = conn.get_all_topics()
    topic_arn = topics_json["ListTopicsResponse"][
        "ListTopicsResult"]["Topics"][0]['TopicArn']

    conn.subscribe(topic_arn, "http", "http://example.com/")

    subscriptions = conn.get_all_subscriptions()["ListSubscriptionsResponse"][
        "ListSubscriptionsResult"]["Subscriptions"]
    subscriptions.should.have.length_of(1)
    subscription = subscriptions[0]
    subscription["TopicArn"].should.equal(topic_arn)
    subscription["Protocol"].should.equal("http")
    subscription["SubscriptionArn"].should.contain(topic_arn)
    subscription["Endpoint"].should.equal("http://example.com/")

    # Now unsubscribe the subscription
    conn.unsubscribe(subscription["SubscriptionArn"])

    # And there should be zero subscriptions left
    subscriptions = conn.get_all_subscriptions()["ListSubscriptionsResponse"][
        "ListSubscriptionsResult"]["Subscriptions"]
    subscriptions.should.have.length_of(0)
Example #11
0
def create_topic():
    """ Create a topic so that we can publish to it. """
    conn = connect_sns()
    conn.create_topic("some-topic")
    topics_json = conn.get_all_topics()
    topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']
    return topic_arn
Example #12
0
def test_creating_subscription():
    conn = boto.connect_sns()
    conn.create_topic("some-topic")
    topics_json = conn.get_all_topics()
    topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"][
        "Topics"][0]["TopicArn"]

    conn.subscribe(topic_arn, "http", "http://example.com/")

    subscriptions = conn.get_all_subscriptions(
    )["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["Subscriptions"]
    subscriptions.should.have.length_of(1)
    subscription = subscriptions[0]
    subscription["TopicArn"].should.equal(topic_arn)
    subscription["Protocol"].should.equal("http")
    subscription["SubscriptionArn"].should.contain(topic_arn)
    subscription["Endpoint"].should.equal("http://example.com/")

    # Now unsubscribe the subscription
    conn.unsubscribe(subscription["SubscriptionArn"])

    # And there should be zero subscriptions left
    subscriptions = conn.get_all_subscriptions(
    )["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["Subscriptions"]
    subscriptions.should.have.length_of(0)
Example #13
0
def test_delete_endpoint():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(
        name="my-application",
        platform="APNS",
    )
    application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']

    endpoint = conn.create_platform_endpoint(
        platform_application_arn=application_arn,
        token="some_unique_id",
        custom_user_data="some user data",
        attributes={
            "Enabled": False,
            "CustomUserData": "some data",
        },
    )
    endpoint_arn = endpoint['CreatePlatformEndpointResponse']['CreatePlatformEndpointResult']['EndpointArn']

    endpoint_list = conn.list_endpoints_by_platform_application(
        platform_application_arn=application_arn
    )['ListEndpointsByPlatformApplicationResponse']['ListEndpointsByPlatformApplicationResult']['Endpoints']

    endpoint_list.should.have.length_of(1)

    conn.delete_endpoint(endpoint_arn)

    endpoint_list = conn.list_endpoints_by_platform_application(
        platform_application_arn=application_arn
    )['ListEndpointsByPlatformApplicationResponse']['ListEndpointsByPlatformApplicationResult']['Endpoints']
    endpoint_list.should.have.length_of(0)
Example #14
0
def test_get_list_endpoints_by_platform_application():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(
        name="my-application", platform="APNS"
    )
    application_arn = platform_application["CreatePlatformApplicationResponse"][
        "CreatePlatformApplicationResult"
    ]["PlatformApplicationArn"]

    endpoint = conn.create_platform_endpoint(
        platform_application_arn=application_arn,
        token="some_unique_id",
        custom_user_data="some user data",
        attributes={"CustomUserData": "some data"},
    )
    endpoint_arn = endpoint["CreatePlatformEndpointResponse"][
        "CreatePlatformEndpointResult"
    ]["EndpointArn"]

    endpoint_list = conn.list_endpoints_by_platform_application(
        platform_application_arn=application_arn
    )["ListEndpointsByPlatformApplicationResponse"][
        "ListEndpointsByPlatformApplicationResult"
    ][
        "Endpoints"
    ]

    endpoint_list.should.have.length_of(1)
    endpoint_list[0]["Attributes"]["CustomUserData"].should.equal("some data")
    endpoint_list[0]["EndpointArn"].should.equal(endpoint_arn)
Example #15
0
def test_delete_endpoint():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(name="my-application", platform="APNS")
    application_arn = platform_application["CreatePlatformApplicationResponse"]["CreatePlatformApplicationResult"][
        "PlatformApplicationArn"
    ]

    endpoint = conn.create_platform_endpoint(
        platform_application_arn=application_arn,
        token="some_unique_id",
        custom_user_data="some user data",
        attributes={"Enabled": False, "CustomUserData": "some data"},
    )
    endpoint_arn = endpoint["CreatePlatformEndpointResponse"]["CreatePlatformEndpointResult"]["EndpointArn"]

    endpoint_list = conn.list_endpoints_by_platform_application(platform_application_arn=application_arn)[
        "ListEndpointsByPlatformApplicationResponse"
    ]["ListEndpointsByPlatformApplicationResult"]["Endpoints"]

    endpoint_list.should.have.length_of(1)

    conn.delete_endpoint(endpoint_arn)

    endpoint_list = conn.list_endpoints_by_platform_application(platform_application_arn=application_arn)[
        "ListEndpointsByPlatformApplicationResponse"
    ]["ListEndpointsByPlatformApplicationResult"]["Endpoints"]
    endpoint_list.should.have.length_of(0)
Example #16
0
def test_set_endpoint_attributes():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(
        name="my-application",
        platform="APNS",
    )
    application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']

    endpoint = conn.create_platform_endpoint(
        platform_application_arn=application_arn,
        token="some_unique_id",
        custom_user_data="some user data",
        attributes={
            "Enabled": False,
            "CustomUserData": "some data",
        },
    )
    endpoint_arn = endpoint['CreatePlatformEndpointResponse']['CreatePlatformEndpointResult']['EndpointArn']

    conn.set_endpoint_attributes(endpoint_arn,
        {"CustomUserData": "other data"}
    )
    attributes = conn.get_endpoint_attributes(endpoint_arn)['GetEndpointAttributesResponse']['GetEndpointAttributesResult']['Attributes']
    attributes.should.equal({
        "Enabled": 'False',
        "CustomUserData": "other data",
    })
Example #17
0
def test_get_list_endpoints_by_platform_application():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(
        name="my-application",
        platform="APNS",
    )
    application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']

    endpoint = conn.create_platform_endpoint(
        platform_application_arn=application_arn,
        token="some_unique_id",
        custom_user_data="some user data",
        attributes={
            "CustomUserData": "some data",
        },
    )
    endpoint_arn = endpoint['CreatePlatformEndpointResponse']['CreatePlatformEndpointResult']['EndpointArn']

    endpoint_list = conn.list_endpoints_by_platform_application(
        platform_application_arn=application_arn
    )['ListEndpointsByPlatformApplicationResponse']['ListEndpointsByPlatformApplicationResult']['Endpoints']

    endpoint_list.should.have.length_of(1)
    endpoint_list[0]['Attributes']['CustomUserData'].should.equal('some data')
    endpoint_list[0]['EndpointArn'].should.equal(endpoint_arn)
Example #18
0
def test_set_endpoint_attributes():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(
        name="my-application", platform="APNS"
    )
    application_arn = platform_application["CreatePlatformApplicationResponse"][
        "CreatePlatformApplicationResult"
    ]["PlatformApplicationArn"]

    endpoint = conn.create_platform_endpoint(
        platform_application_arn=application_arn,
        token="some_unique_id",
        custom_user_data="some user data",
        attributes={"Enabled": False, "CustomUserData": "some data"},
    )
    endpoint_arn = endpoint["CreatePlatformEndpointResponse"][
        "CreatePlatformEndpointResult"
    ]["EndpointArn"]

    conn.set_endpoint_attributes(endpoint_arn, {"CustomUserData": "other data"})
    attributes = conn.get_endpoint_attributes(endpoint_arn)[
        "GetEndpointAttributesResponse"
    ]["GetEndpointAttributesResult"]["Attributes"]
    attributes.should.equal(
        {"Token": "some_unique_id", "Enabled": "false", "CustomUserData": "other data"}
    )
Example #19
0
 def setUp(self):
   self.s3_connection = connect_s3()
   self.sdb_connection = connect_sdb()
   self.sns_connection = connect_sns()
   self.sqs_connection = connect_sqs()
   self.gpg = GPG()
   self.event_handler = LockboxEventHandler()
Example #20
0
    def __init__(self, enc_password=""):
        if enc_password == "":
            print "AWS_SNS: Enter your AWS file encryption password."
            enc_password = getpass.getpass()#raw_input()
        try:
            f = open('./config/salt.txt','r')
            salt = f.read()
            f.close()
            hash_pass = hashlib.sha256(enc_password + salt).digest()

            f = open('./config/aws_api_key.txt')
            ciphertext = f.read()
            f.close()
            decryptor = AES.new(hash_pass, AES.MODE_CBC,ciphertext[:AES.block_size])
            plaintext = decryptor.decrypt(ciphertext[AES.block_size:])
            d = json.loads(plaintext)
            self.key = d['key']
            self.secret = d['secret']
            self.topic_arn = d['topic_arn']
        except:
            print "\n\n\nError: you may have entered an invalid password or the encrypted api key file doesn't exist"
            print "If you haven't yet generated the encrypted key file, run the encrypt_aws_key.py script.\n"
            print "Note: Text messaging services requires an AWS subscription with Amazon.com"
            while 1:
                pass

        self.connection = boto.connect_sns(self.key, self.secret)
Example #21
0
    def setUp(self):
        from ddbmock import connect_boto_patch
        from ddbmock.database.db import dynamodb
        from ddbmock.database.table import Table
        from ddbmock.database.key import PrimaryKey

        # Do a full database wipe
        dynamodb.hard_reset()

        # Instanciate the keys
        hash_key = PrimaryKey(self.TABLE_HK_NAME, self.TABLE_HK_TYPE)

        # Create a test table
        new_table = Table(self.TABLE_NAME, self.TABLE_RT, self.TABLE_WT,
                          hash_key, None)

        # Very important: register the table in the DB
        dynamodb.data[self.TABLE_NAME] = new_table

        # Create the database connection ie: patch boto
        self.db = connect_boto_patch()

        self.table = self.db.get_table(self.TABLE_NAME)
        self.sns_conn = boto.connect_sns()

        self.memon = MEMon()
        self.memon.debug = False
        self.memon.table = self.table
        self.memon.sns_conn = self.sns_conn
        self.memon.server_time = False
Example #22
0
    def setUp(self):
        from ddbmock import connect_boto_patch
        from ddbmock.database.db import dynamodb
        from ddbmock.database.table import Table
        from ddbmock.database.key import PrimaryKey

        # Do a full database wipe
        dynamodb.hard_reset()

        # Instanciate the keys
        hash_key = PrimaryKey(self.TABLE_HK_NAME, self.TABLE_HK_TYPE)

        # Create a test table
        new_table = Table(self.TABLE_NAME,
                          self.TABLE_RT,
                          self.TABLE_WT,
                          hash_key,
                          None)

        # Very important: register the table in the DB
        dynamodb.data[self.TABLE_NAME] = new_table

        # Create the database connection ie: patch boto
        self.db = connect_boto_patch()

        self.table = self.db.get_table(self.TABLE_NAME)
        self.sns_conn = boto.connect_sns()

        self.memon = MEMon()
        self.memon.debug = False
        self.memon.table = self.table
        self.memon.sns_conn = self.sns_conn
        self.memon.server_time = False
Example #23
0
def test_publish_to_http():
    httpretty.HTTPretty.register_uri(
        method="POST",
        uri="http://example.com/foobar",
    )

    conn = boto.connect_sns()
    conn.create_topic("some-topic")
    topics_json = conn.get_all_topics()
    topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']

    conn.subscribe(topic_arn, "http", "http://example.com/foobar")

    response = conn.publish(topic=topic_arn, message="my message", subject="my subject")
    message_id = response['PublishResponse']['PublishResult']['MessageId']

    last_request = httpretty.last_request()
    last_request.method.should.equal("POST")
    parse_qs(last_request.body).should.equal({
        "Type": ["Notification"],
        "MessageId": [message_id],
        "TopicArn": ["arn:aws:sns:us-east-1:123456789012:some-topic"],
        "Subject": ["my subject"],
        "Message": ["my message"],
        "Timestamp": ["2013-01-01T00:00:00Z"],
        "SignatureVersion": ["1"],
        "Signature": ["EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc="],
        "SigningCertURL": ["https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem"],
        "UnsubscribeURL": ["https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:123456789012:some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"],
    })
Example #24
0
def test_subscription_paging():
    conn = boto.connect_sns()
    conn.create_topic("topic1")
    conn.create_topic("topic2")

    topics_json = conn.get_all_topics()
    topics = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
    topic1_arn = topics[0]['TopicArn']
    topic2_arn = topics[1]['TopicArn']

    for index in range(DEFAULT_PAGE_SIZE + int(DEFAULT_PAGE_SIZE / 3)):
        conn.subscribe(topic1_arn, 'email', 'email_' + str(index) + '@test.com')
        conn.subscribe(topic2_arn, 'email', 'email_' + str(index) + '@test.com')

    all_subscriptions = conn.get_all_subscriptions()
    all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["Subscriptions"].should.have.length_of(DEFAULT_PAGE_SIZE)
    next_token = all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["NextToken"]
    next_token.should.equal(DEFAULT_PAGE_SIZE)

    all_subscriptions = conn.get_all_subscriptions(next_token=next_token * 2)
    all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["Subscriptions"].should.have.length_of(int(DEFAULT_PAGE_SIZE * 2 / 3))
    next_token = all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["NextToken"]
    next_token.should.equal(None)

    topic1_subscriptions = conn.get_all_subscriptions_by_topic(topic1_arn)
    topic1_subscriptions["ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"]["Subscriptions"].should.have.length_of(DEFAULT_PAGE_SIZE)
    next_token = topic1_subscriptions["ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"]["NextToken"]
    next_token.should.equal(DEFAULT_PAGE_SIZE)

    topic1_subscriptions = conn.get_all_subscriptions_by_topic(topic1_arn, next_token=next_token)
    topic1_subscriptions["ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"]["Subscriptions"].should.have.length_of(int(DEFAULT_PAGE_SIZE / 3))
    next_token = topic1_subscriptions["ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"]["NextToken"]
    next_token.should.equal(None)
    def test_publish_to_sns(self):

        MESSAGE_FROM_SQS_TEMPLATE = '{\n  "Message": "%s",\n  "MessageId": "%s"\n}'

        conn = boto.connect_sns()
        conn.create_topic("some-topic")
        topics_json = conn.get_all_topics()
        topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"][
            "Topics"][0]['TopicArn']

        sqs_conn = boto.connect_sqs()
        sqs_conn.create_queue("test-queue")

        conn.subscribe(topic_arn, "sqs",
                       "arn:aws:sqs:us-east-1:123456789012:test-queue")

        message_to_publish = 'my message'
        subject_to_publish = "test subject"
        with freeze_time("2015-01-01 12:00:00"):
            published_message = publish_to_sns(conn, '123456789012',
                                               'us-east-1', message_to_publish)

        published_message_id = published_message['MessageId']

        queue = sqs_conn.get_queue("test-queue")
        message = queue.read(1)
        expected = MESSAGE_FROM_SQS_TEMPLATE % (
            message_to_publish, published_message_id, subject_to_publish,
            'us-east-1')
        acquired_message = re.sub(
            "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z",
            '2015-01-01T12:00:00.000Z', message.get_body())
        acquired_message.should.equal(expected)
Example #26
0
 def __init__(self, medium_id, spam_sensitivity=None):
     aws_key = settings.NOTIFICATION_AWS_KEY
     aws_secret = settings.NOTIFICATION_AWS_SECRET
 
     self.sns = connect_sns(aws_key,
                            aws_secret)
     super(SnsBackend, self).__init__(medium_id, spam_sensitivity)
Example #27
0
    def __init__(self, enc_password=""):
        if enc_password == "":
            print "AWS_SNS: Enter your AWS file encryption password."
            enc_password = getpass.getpass()  #raw_input()
        try:
            f = open('./config/salt.txt', 'r')
            salt = f.read()
            f.close()
            hash_pass = hashlib.sha256(enc_password + salt).digest()

            f = open('./config/aws_api_key.txt')
            ciphertext = f.read()
            f.close()
            decryptor = AES.new(hash_pass, AES.MODE_CBC,
                                ciphertext[:AES.block_size])
            plaintext = decryptor.decrypt(ciphertext[AES.block_size:])
            d = json.loads(plaintext)
            self.key = d['key']
            self.secret = d['secret']
            self.topic_arn = d['topic_arn']
        except:
            print "\n\n\nError: you may have entered an invalid password or the encrypted api key file doesn't exist"
            print "If you haven't yet generated the encrypted key file, run the encrypt_aws_key.py script.\n"
            print "Note: Text messaging services requires an AWS subscription with Amazon.com"
            while 1:
                pass

        self.connection = boto.connect_sns(self.key, self.secret)
Example #28
0
def test_publish_to_platform_endpoint():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(
        name="my-application",
        platform="APNS",
    )
    application_arn = platform_application[
        'CreatePlatformApplicationResponse'][
            'CreatePlatformApplicationResult']['PlatformApplicationArn']

    endpoint = conn.create_platform_endpoint(
        platform_application_arn=application_arn,
        token="some_unique_id",
        custom_user_data="some user data",
        attributes={
            "Enabled": False,
        },
    )

    endpoint_arn = endpoint['CreatePlatformEndpointResponse'][
        'CreatePlatformEndpointResult']['EndpointArn']

    conn.publish(message="some message",
                 message_structure="json",
                 target_arn=endpoint_arn)
Example #29
0
def send_email_notification(sub,msg):
    sns = boto.connect_sns()
    sns=boto.sns.connect_to_region('us-west-2')
    topics = sns.get_all_topics()
    mytopics = topics["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
    for t in mytopics:
        res = sns.publish(t["TopicArn"], msg, sub)
        print (str(res))
Example #30
0
def _notify_sns(iam, topic, msg):
    sns = boto.connect_sns(
        aws_access_key_id=AWS_SETTINGS['iam'][iam]['AWS_ACCESS_KEY_ID'],
        aws_secret_access_key=AWS_SETTINGS['iam'][iam]['AWS_SECRET_ACCESS_KEY'])

    if topic in AWS_SETTINGS['topics']:
        print "Sending notification to {t} ...".format(t=getTopic(topic))
        res = sns.publish(getTopic(topic), msg)
Example #31
0
def send_sns(opts, msg):
    sns = boto.connect_sns()
    
    arn = opts.arn
    if opts.rate_limit:
        rate_limit(sns, arn, msg, opts.subject)   
    else:
        print sns.publish(topic=arn, message=msg, subject=opts.subject)
Example #32
0
def link_sqs_sns():
    sns = boto.connect_sns()
    sqs = boto.connect_sqs()

    queue = sqs.create_queue('asg_notifications', 300)
    topic = sns.create_topic('asg_notifications')

    sns.subscribe_sqs_queue(topic['CreateTopicResponse']['CreateTopicResult']['TopicArn'], queue)
Example #33
0
 def aws_connection(cls, topic_label):
     if not cls._aws_connection:
         for r in boto.sns.regions():
             if (':%s:' % r.name) in topic_label:
                 region = r
                 break
         cls._aws_connection = boto.connect_sns(settings.AWS_ACCESS_KEY_ID , settings.AWS_SECRET_ACCESS_KEY, region=region)
     return cls._aws_connection
Example #34
0
def init():

  import boto
  
  res = globals()

  res["ec2"] = boto.connect_ec2()
  res["sns"] = boto.connect_sns()
Example #35
0
def test_list_platform_applications():
    conn = boto.connect_sns()
    conn.create_platform_application(name="application1", platform="APNS")
    conn.create_platform_application(name="application2", platform="APNS")

    applications_response = conn.list_platform_applications()
    applications = applications_response["ListPlatformApplicationsResponse"][
        "ListPlatformApplicationsResult"]["PlatformApplications"]
    applications.should.have.length_of(2)
Example #36
0
 def create_topic():
     """
     {'CreateTopicResponse': 
         {'ResponseMetadata': 
             {'RequestId': '5e2c6700-4dd0-11e1-b421-41716ce69b95'}, 
         'CreateTopicResult': {'TopicArn': 'arn:aws:sns:us-east-1:674707187858:election'}}}
     """
     snsconn = boto.connect_sns()
     snsconn.create_topic(topic_name)
Example #37
0
 def create_topic(self, topic_name):
     sns_connection = boto.connect_sns(aws_access_key_id=self._conf['SNS_KEYID'], aws_secret_access_key=self._conf['SNS_KEY'])
     if sns_connection==None:
         loger.error('AWS sns connect failed')
         return none
     ret = sns_connection.create_topic(topic_name)
     if ret==None:
         log.error('AWS topic create failed for %s' % topic_name)
         return none
     return ret
Example #38
0
    def register_device(self, device):
        attributes = {'Enabled': True}

        boto.connect_sns(
            aws_access_key_id=self.aws_access_key_id,
            aws_secret_access_key=self.aws_secret_access_key)

        sns_conn = boto.sns.connect_to_region(
            region_name=self.aws_sns_region,
            aws_access_key_id=self.aws_access_key_id,
            aws_secret_access_key=self.aws_secret_access_key)

        response = sns_conn.create_platform_endpoint(
            token=device.token, platform_application_arn=self.aws_android_arn,
            attributes=attributes)
        response_key = 'CreatePlatformEndpointResponse'
        result_key = 'CreatePlatformEndpointResult'
        arn = response[response_key][result_key]['EndpointArn']
        return arn
    def __init__(self, arn):
        self.arn = arn
        self.messages = []
        self.sns = boto.connect_sns()
        self.env, self.instance_id, self.instance_type = Pub.get_ec2_info()

        cherrypy.Tool.__init__(self,
                               'on_end_request',
                               self.publish,
                               priority=100)
Example #40
0
    def register_device(self, device):
        attributes = {'Enabled': True}

        boto.connect_sns(aws_access_key_id=self.aws_access_key_id,
                         aws_secret_access_key=self.aws_secret_access_key)

        sns_conn = boto.sns.connect_to_region(
            region_name=self.aws_sns_region,
            aws_access_key_id=self.aws_access_key_id,
            aws_secret_access_key=self.aws_secret_access_key)

        response = sns_conn.create_platform_endpoint(
            token=device.token,
            platform_application_arn=self.aws_android_arn,
            attributes=attributes)
        response_key = 'CreatePlatformEndpointResponse'
        result_key = 'CreatePlatformEndpointResult'
        arn = response[response_key][result_key]['EndpointArn']
        return arn
Example #41
0
def test_list_platform_applications():
    conn = boto.connect_sns()
    conn.create_platform_application(name="application1", platform="APNS")
    conn.create_platform_application(name="application2", platform="APNS")

    applications_repsonse = conn.list_platform_applications()
    applications = applications_repsonse["ListPlatformApplicationsResponse"]["ListPlatformApplicationsResult"][
        "PlatformApplications"
    ]
    applications.should.have.length_of(2)
Example #42
0
def test_topic_attributes():
    conn = boto.connect_sns()
    conn.create_topic("some-topic")

    topics_json = conn.get_all_topics()
    topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"][
        "Topics"][0]['TopicArn']

    attributes = conn.get_topic_attributes(topic_arn)[
        'GetTopicAttributesResponse']['GetTopicAttributesResult']['Attributes']
    attributes["TopicArn"].should.equal(
        "arn:aws:sns:{0}:123456789012:some-topic".format(conn.region.name))
    attributes["Owner"].should.equal(123456789012)
    attributes["Policy"].should.equal(DEFAULT_TOPIC_POLICY)
    attributes["DisplayName"].should.equal("")
    attributes["SubscriptionsPending"].should.equal(0)
    attributes["SubscriptionsConfirmed"].should.equal(0)
    attributes["SubscriptionsDeleted"].should.equal(0)
    attributes["DeliveryPolicy"].should.equal("")
    attributes["EffectiveDeliveryPolicy"].should.equal(
        DEFAULT_EFFECTIVE_DELIVERY_POLICY)

    # boto can't handle prefix-mandatory strings:
    # i.e. unicode on Python 2 -- u"foobar"
    # and bytes on Python 3 -- b"foobar"
    if six.PY2:
        policy = {b"foo": b"bar"}
        displayname = b"My display name"
        delivery = {
            b"http": {
                b"defaultHealthyRetryPolicy": {
                    b"numRetries": 5
                }
            }
        }
    else:
        policy = {u"foo": u"bar"}
        displayname = u"My display name"
        delivery = {
            u"http": {
                u"defaultHealthyRetryPolicy": {
                    u"numRetries": 5
                }
            }
        }
    conn.set_topic_attributes(topic_arn, "Policy", policy)
    conn.set_topic_attributes(topic_arn, "DisplayName", displayname)
    conn.set_topic_attributes(topic_arn, "DeliveryPolicy", delivery)

    attributes = conn.get_topic_attributes(topic_arn)[
        'GetTopicAttributesResponse']['GetTopicAttributesResult']['Attributes']
    attributes["Policy"].should.equal("{'foo': 'bar'}")
    attributes["DisplayName"].should.equal("My display name")
    attributes["DeliveryPolicy"].should.equal(
        "{'http': {'defaultHealthyRetryPolicy': {'numRetries': 5}}}")
Example #43
0
def test_create_platform_application():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(
        name="my-application",
        platform="APNS",
        attributes={"PlatformCredential": "platform_credential", "PlatformPrincipal": "platform_principal"},
    )
    application_arn = platform_application["CreatePlatformApplicationResponse"]["CreatePlatformApplicationResult"][
        "PlatformApplicationArn"
    ]
    application_arn.should.equal("arn:aws:sns:us-east-1:123456789012:app/APNS/my-application")
Example #44
0
 def aws_connection(cls, topic_label):
     if not cls._aws_connection:
         for r in boto.sns.regions():
             if (':%s:' % r.name) in topic_label:
                 region = r
                 break
         cls._aws_connection = boto.connect_sns(
             settings.AWS_ACCESS_KEY_ID,
             settings.AWS_SECRET_ACCESS_KEY,
             region=region)
     return cls._aws_connection
Example #45
0
def get_arn(key, secret, topic, endpoint=None, type='email'):
    sns = boto.connect_sns(key, secret)
    if not endpoint:
        topics = sns.get_all_topics()
        topic_arns = [i['TopicArn'] for i in topics[
            'ListTopicsResponse']['ListTopicsResult']['Topics']]
        arn = filter(lambda i: i.split(':')[-1] == topic, topic_arns)[0]
    else:
        topic = sns.create_topic(topic)
        arn = topic['CreateTopicResponse']['CreateTopicResult']['TopicArn']
        sns.subscribe(arn, type, endpoint)
    return arn
Example #46
0
def test_create_platform_application():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(
        name="my-application",
        platform="APNS",
        attributes={
            "PlatformCredential": "platform_credential",
            "PlatformPrincipal": "platform_principal",
        },
    )
    application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']
    application_arn.should.equal('arn:aws:sns:us-east-1:123456789012:app/APNS/my-application')
Example #47
0
 def save(self, **kwargs):
     super(Topic, self).save(**kwargs)
     
     try:
         import boto
         conn = boto.connect_sns(AWS.access_key(), AWS.access_key_secret())
         res = conn.create_topic(self.slug.encode('utf8'))
         arn = res['CreateTopicResponse']['CreateTopicResult']['TopicArn']
         self.arn = arn
         super(Topic, self).save(update_fields=['arn'])
     except:
         pass
Example #48
0
def printinfo(arn):
	sns=boto.connect_sns();
	dic= sns.get_topic_attributes(arn)['GetTopicAttributesResponse']['GetTopicAttributesResult']['Attributes']
	for x, y in dic.items():
		if x=="EffectiveDeliveryPolicy" or x=="Policy":
			pass
		else:
			print x, y
			print ""
	print dic['EffectiveDeliveryPolicy']
	print ""
	print dic['Policy']
	print ""
Example #49
0
def final_time():
  logging.info('We are entering the final time.')
  credentials = Credentials(database_directory=FLAGS.internal_directory)
  owners_data = credentials.owner()
  print owners_data

  for (group_id, aws_access_key_id, aws_secret_access_key) in owners_data:
    sns_connection = boto.connect_sns(aws_access_key_id, aws_secret_access_key)
    sqs_connection = boto.connect_sqs(aws_access_key_id, aws_secret_access_key)
    iam_connection = boto.connect_iam(aws_access_key_id, aws_secret_access_key)
    group_manager = GroupManager(sns_connection, sqs_connection, iam_connection,
                                 database_directory=FLAGS.internal_directory)
    group_manager.delete_group(group_id)
Example #50
0
def test_list_platform_applications():
    conn = boto.connect_sns()
    conn.create_platform_application(
        name="application1",
        platform="APNS",
    )
    conn.create_platform_application(
        name="application2",
        platform="APNS",
    )

    applications_repsonse = conn.list_platform_applications()
    applications = applications_repsonse['ListPlatformApplicationsResponse']['ListPlatformApplicationsResult']['PlatformApplications']
    applications.should.have.length_of(2)
Example #51
0
def printinfo(arn):
    sns = boto.connect_sns()
    dic = sns.get_topic_attributes(arn)['GetTopicAttributesResponse'][
        'GetTopicAttributesResult']['Attributes']
    for x, y in dic.items():
        if x == "EffectiveDeliveryPolicy" or x == "Policy":
            pass
        else:
            print x, y
            print ""
    print dic['EffectiveDeliveryPolicy']
    print ""
    print dic['Policy']
    print ""
Example #52
0
def test_create_platform_application():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(
        name="my-application",
        platform="APNS",
        attributes={
            "PlatformCredential": "platform_credential",
            "PlatformPrincipal": "platform_principal",
        },
    )
    application_arn = platform_application[
        "CreatePlatformApplicationResponse"][
            "CreatePlatformApplicationResult"]["PlatformApplicationArn"]
    application_arn.should.equal(
        "arn:aws:sns:us-east-1:{}:app/APNS/my-application".format(ACCOUNT_ID))
Example #53
0
    def __init__(self):
        self.queue = "memon"
        self.table_name = "memon"
        self.table = None
        self.sns = "memon"
        self.sns_email = None
        self.debug = False
        self.max_notify_count = 3
        self.server_time = True

        self.sqs = boto.connect_sqs()
        self.sns_conn = boto.connect_sns()
        self.db = boto.connect_dynamodb()
        self.pp = pprint.PrettyPrinter()
        self.now = int(time.time())
Example #54
0
def test_get_platform_application_attributes():
    conn = boto.connect_sns()
    platform_application = conn.create_platform_application(
        name="my-application",
        platform="APNS",
        attributes={
            "PlatformCredential": "platform_credential",
            "PlatformPrincipal": "platform_principal",
        },
    )
    arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']
    attributes = conn.get_platform_application_attributes(arn)['GetPlatformApplicationAttributesResponse']['GetPlatformApplicationAttributesResult']['Attributes']
    attributes.should.equal({
        "PlatformCredential": "platform_credential",
        "PlatformPrincipal": "platform_principal",
    })
Example #55
0
def test_publish_to_sqs():
    conn = boto.connect_sns()
    conn.create_topic("some-topic")
    topics_json = conn.get_all_topics()
    topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']

    sqs_conn = boto.connect_sqs()
    sqs_conn.create_queue("test-queue")

    conn.subscribe(topic_arn, "sqs", "arn:aws:sqs:us-east-1:123456789012:test-queue")

    conn.publish(topic=topic_arn, message="my message")

    queue = sqs_conn.get_queue("test-queue")
    message = queue.read(1)
    message.get_body().should.equal('my message')
Example #56
0
def test_topic_kms_master_key_id_attribute():
    conn = boto.connect_sns()

    conn.create_topic("test-sns-no-key-attr")
    topics_json = conn.get_all_topics()
    topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"][
        "Topics"][0]["TopicArn"]
    attributes = conn.get_topic_attributes(topic_arn)[
        "GetTopicAttributesResponse"]["GetTopicAttributesResult"]["Attributes"]
    attributes.should_not.have.key("KmsMasterKeyId")

    conn.set_topic_attributes(topic_arn, "KmsMasterKeyId", "test-key")
    attributes = conn.get_topic_attributes(topic_arn)[
        "GetTopicAttributesResponse"]["GetTopicAttributesResult"]["Attributes"]
    attributes.should.have.key("KmsMasterKeyId")
    attributes["KmsMasterKeyId"].should.equal("test-key")
Example #57
0
def test_create_and_delete_topic():
    conn = boto.connect_sns()
    conn.create_topic("some-topic")

    topics_json = conn.get_all_topics()
    topics = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
    topics.should.have.length_of(1)
    topics[0]['TopicArn'].should.equal("arn:aws:sns:us-east-1:123456789012:some-topic")

    # Delete the topic
    conn.delete_topic(topics[0]['TopicArn'])

    # And there should now be 0 topics
    topics_json = conn.get_all_topics()
    topics = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
    topics.should.have.length_of(0)
Example #58
0
def test_getting_subscriptions_by_topic():
    conn = boto.connect_sns()
    conn.create_topic("topic1")
    conn.create_topic("topic2")

    topics_json = conn.get_all_topics()
    topics = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
    topic1_arn = topics[0]['TopicArn']
    topic2_arn = topics[1]['TopicArn']

    conn.subscribe(topic1_arn, "http", "http://example1.com/")
    conn.subscribe(topic2_arn, "http", "http://example2.com/")

    topic1_subscriptions = conn.get_all_subscriptions_by_topic(topic1_arn)[
        "ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"]["Subscriptions"]
    topic1_subscriptions.should.have.length_of(1)
    topic1_subscriptions[0]['Endpoint'].should.equal("http://example1.com/")
Example #59
0
def test_create_and_delete_topic():
    conn = boto.connect_sns()
    conn.create_topic("some-topic")

    topics_json = conn.get_all_topics()
    topics = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
    topics.should.have.length_of(1)
    topics[0]["TopicArn"].should.equal("arn:aws:sns:{0}:{1}:some-topic".format(
        conn.region.name, ACCOUNT_ID))

    # Delete the topic
    conn.delete_topic(topics[0]["TopicArn"])

    # And there should now be 0 topics
    topics_json = conn.get_all_topics()
    topics = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
    topics.should.have.length_of(0)
Example #60
0
def test_subscription_paging():
    conn = boto.connect_sns()
    conn.create_topic("topic1")
    conn.create_topic("topic2")

    topics_json = conn.get_all_topics()
    topics = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
    topic1_arn = topics[0]["TopicArn"]
    topic2_arn = topics[1]["TopicArn"]

    for index in range(DEFAULT_PAGE_SIZE + int(DEFAULT_PAGE_SIZE / 3)):
        conn.subscribe(topic1_arn, "email",
                       "email_" + str(index) + "@test.com")
        conn.subscribe(topic2_arn, "email",
                       "email_" + str(index) + "@test.com")

    all_subscriptions = conn.get_all_subscriptions()
    all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"][
        "Subscriptions"].should.have.length_of(DEFAULT_PAGE_SIZE)
    next_token = all_subscriptions["ListSubscriptionsResponse"][
        "ListSubscriptionsResult"]["NextToken"]
    next_token.should.equal(DEFAULT_PAGE_SIZE)

    all_subscriptions = conn.get_all_subscriptions(next_token=next_token * 2)
    all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"][
        "Subscriptions"].should.have.length_of(int(DEFAULT_PAGE_SIZE * 2 / 3))
    next_token = all_subscriptions["ListSubscriptionsResponse"][
        "ListSubscriptionsResult"]["NextToken"]
    next_token.should.equal(None)

    topic1_subscriptions = conn.get_all_subscriptions_by_topic(topic1_arn)
    topic1_subscriptions["ListSubscriptionsByTopicResponse"][
        "ListSubscriptionsByTopicResult"][
            "Subscriptions"].should.have.length_of(DEFAULT_PAGE_SIZE)
    next_token = topic1_subscriptions["ListSubscriptionsByTopicResponse"][
        "ListSubscriptionsByTopicResult"]["NextToken"]
    next_token.should.equal(DEFAULT_PAGE_SIZE)

    topic1_subscriptions = conn.get_all_subscriptions_by_topic(
        topic1_arn, next_token=next_token)
    topic1_subscriptions["ListSubscriptionsByTopicResponse"][
        "ListSubscriptionsByTopicResult"][
            "Subscriptions"].should.have.length_of(int(DEFAULT_PAGE_SIZE / 3))
    next_token = topic1_subscriptions["ListSubscriptionsByTopicResponse"][
        "ListSubscriptionsByTopicResult"]["NextToken"]
    next_token.should.equal(None)