PayWithAmazon\IpnHandlertest::testValidateUrl PHP Method

testValidateUrl() public method

public testValidateUrl ( )
    public function testValidateUrl()
    {
        $headers = array('x-amz-sns-message-type' => 'Notification');
        try {
            $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"http://sns.us-east-1.amazonaws.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.pem"}';
            $ipnHandler = new IpnHandler($headers, $body, $this->configParams);
        } catch (\Exception $expected) {
            $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected));
        }
        try {
            $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"https://sns.us-east-1.amazonaws.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.exe"}';
            $ipnHandler = new IpnHandler($headers, $body, $this->configParams);
        } catch (\Exception $expected) {
            $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected));
        }
        try {
            $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"https://sns.us-east-1.example.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.pem"}';
            $ipnHandler = new IpnHandler($headers, $body, $this->configParams);
        } catch (\Exception $expected) {
            $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected));
        }
        try {
            $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"https://sni.us-east-1.amazonaws.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.pem"}';
            $ipnHandler = new IpnHandler($headers, $body, $this->configParams);
        } catch (\Exception $expected) {
            $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected));
        }
        try {
            $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"https://sns.us.amazonaws.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.pem"}';
            $ipnHandler = new IpnHandler($headers, $body, $this->configParams);
        } catch (\Exception $expected) {
            $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected));
        }
        try {
            $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"https://sns.us-east-1.amazonaws.com.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.pem"}';
            $ipnHandler = new IpnHandler($headers, $body, $this->configParams);
        } catch (\Exception $expected) {
            $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected));
        }
    }