Example #1
0
    def test_get_works(self):
        record_id = 'RID'
        audit_log.AuditDAO.get(record_id).AndReturn('RECORD')
        audit_log.record_to_view('RECORD').AndReturn('REPLY')

        self.mox.ReplayAll()
        rv = self.client.get('/v1/audit-log/%s' % record_id)
        data = self.check_and_parse_response(rv)
        self.assertEquals(data, 'REPLY')
    def test_get_works(self):
        record_id = 'RID'
        audit_log.AuditDAO.get(record_id).AndReturn('RECORD')
        audit_log.record_to_view('RECORD').AndReturn('REPLY')

        self.mox.ReplayAll()
        rv = self.client.get('/v1/audit-log/%s' % record_id)
        data = self.check_and_parse_response(rv)
        self.assertEquals(data, 'REPLY')
Example #3
0
    def test_list_works(self):
        audit_log.AuditDAO.list_all().AndReturn(['A1', 'A2'])
        audit_log.record_to_view('A1').AndReturn('R1')
        audit_log.record_to_view('A2').AndReturn('R2')
        expected = {
            'collection': {
                'name': 'audit-log',
                'size': 2
            },
            'audit-log': ['R1', 'R2']
        }

        self.mox.ReplayAll()
        rv = self.client.get('/v1/audit-log/')
        data = self.check_and_parse_response(rv)
        self.assertEquals(data, expected)
Example #4
0
    def test_all_nones(self):
        record = AuditRecord(user_id=None, project_id=None)
        audit_log._record_to_dict(record, None, None).AndReturn('REPLY')

        self.mox.ReplayAll()
        reply = audit_log.record_to_view(record)
        self.assertEquals('REPLY', reply)
    def test_list_works(self):
        audit_log.AuditDAO.list_all().AndReturn(['A1', 'A2'])
        audit_log.record_to_view('A1').AndReturn('R1')
        audit_log.record_to_view('A2').AndReturn('R2')
        expected = {
            'collection': {
                'name': 'audit-log',
                'size': 2
            },
            'audit-log': [ 'R1', 'R2' ]
        }

        self.mox.ReplayAll()
        rv = self.client.get('/v1/audit-log/')
        data = self.check_and_parse_response(rv)
        self.assertEquals(data, expected)
    def test_all_nones(self):
        record = AuditRecord(user_id=None, project_id=None)
        audit_log._record_to_dict(record, None, None).AndReturn('REPLY')

        self.mox.ReplayAll()
        reply = audit_log.record_to_view(record)
        self.assertEquals('REPLY', reply)
Example #7
0
    def test_has_project_name(self):
        record = AuditRecord(project_id='PID', user_id=None)
        audit_log._record_to_dict(record, None, 'project')\
                .AndReturn('REPLY')

        self.mox.ReplayAll()
        reply = audit_log.record_to_view(record, None, 'project')
        self.assertEquals('REPLY', reply)
    def test_has_project_name(self):
        record = AuditRecord(project_id='PID', user_id=None)
        audit_log._record_to_dict(record, None, 'project')\
                .AndReturn('REPLY')

        self.mox.ReplayAll()
        reply = audit_log.record_to_view(record, None, 'project')
        self.assertEquals('REPLY', reply)
Example #9
0
    def test_project_not_found(self):
        record = AuditRecord(project_id='PID', user_id=None)
        self.iadm.tenants.get('PID').AndRaise(osc_exc.NotFound('failure'))
        audit_log._record_to_dict(record, None, None)\
                .AndReturn('REPLY')

        self.mox.ReplayAll()
        reply = audit_log.record_to_view(record)
        self.assertEquals('REPLY', reply)
    def test_project_not_found(self):
        record = AuditRecord(project_id='PID', user_id=None)
        self.iadm.tenants.get('PID').AndRaise(osc_exc.NotFound('failure'))
        audit_log._record_to_dict(record, None, None)\
                .AndReturn('REPLY')

        self.mox.ReplayAll()
        reply = audit_log.record_to_view(record)
        self.assertEquals('REPLY', reply)
Example #11
0
    def test_get_project_name(self):
        record = AuditRecord(project_id='PID', user_id=None)
        project = doubles.make(self.mox, doubles.Tenant, name='PROJECT')
        self.iadm.tenants.get('PID').AndReturn(project)
        audit_log._record_to_dict(record, None, 'PROJECT')\
                .AndReturn('REPLY')

        self.mox.ReplayAll()
        reply = audit_log.record_to_view(record)
        self.assertEquals('REPLY', reply)
Example #12
0
    def test_get_user_name(self):
        record = AuditRecord(user_id='UID', project_id=None)
        user = doubles.make(self.mox, doubles.User, name='USERNAME')
        self.iadm.users.get('UID').AndReturn(user)
        audit_log._record_to_dict(record, 'USERNAME', None)\
                .AndReturn('REPLY')

        self.mox.ReplayAll()
        reply = audit_log.record_to_view(record)
        self.assertEquals('REPLY', reply)
    def test_get_project_name(self):
        record = AuditRecord(project_id='PID', user_id=None)
        project = doubles.make(self.mox, doubles.Tenant, name='PROJECT')
        self.iadm.tenants.get('PID').AndReturn(project)
        audit_log._record_to_dict(record, None, 'PROJECT')\
                .AndReturn('REPLY')

        self.mox.ReplayAll()
        reply = audit_log.record_to_view(record)
        self.assertEquals('REPLY', reply)
    def test_get_user_name(self):
        record = AuditRecord(user_id='UID', project_id=None)
        user = doubles.make(self.mox, doubles.User, name='USERNAME')
        self.iadm.users.get('UID').AndReturn(user)
        audit_log._record_to_dict(record, 'USERNAME', None)\
                .AndReturn('REPLY')

        self.mox.ReplayAll()
        reply = audit_log.record_to_view(record)
        self.assertEquals('REPLY', reply)