コード例 #1
0
    def test_create_rule_late_not_found(self):
        fw_rules._get_security_group(self.sgid).AndReturn(self.sg)
        fw_rules.auth.client_set_for_tenant('PID', fallback_to_api=True,
                                            eperm_status=404) \
                .AndReturn(self.tcs)
        self.tcs.compute.security_group_rules.create(
            parent_group_id=self.sgid,
            ip_protocol=u'tcp',
            from_port=-1,
            to_port=-1,
            cidr='10.0.0.0/8')\
                .AndRaise(osc_exc.NotFound('gone'))

        self.mox.ReplayAll()
        self.interact({ u'protocol': u'TCP', u'source': u'10.0.0.0/8' },
                      expected_status_code=404)
コード例 #2
0
    def test_create_rule_no_ports(self):
        fw_rules._get_security_group(self.sgid).AndReturn(self.sg)
        fw_rules.auth.client_set_for_tenant('PID', fallback_to_api=True,
                                            eperm_status=404) \
                .AndReturn(self.tcs)
        self.tcs.compute.security_group_rules.create(
            parent_group_id=self.sgid,
            ip_protocol=u'tcp',
            from_port=-1,
            to_port=-1,
            cidr='10.0.0.0/8').AndReturn('Created rule')
        fw_rules._fw_rule_object_to_view('Created rule').AndReturn('REPLY')

        self.mox.ReplayAll()

        data = self.interact({ u'protocol': u'TCP', u'source': u'10.0.0.0/8' })
        self.assertEquals(data, 'REPLY')