예제 #1
0
    def test_dissociate_errors(self):
        fake_user = confd.users(FAKE_ID).funckeys.templates(
            self.template['id']).delete
        fake_template = confd.users(
            self.user['id']).funckeys.templates(FAKE_ID).delete

        s.check_resource_not_found(fake_user, 'User')
        s.check_resource_not_found(fake_template, 'FuncKeyTemplate')
예제 #2
0
def test_associate_multiple_users_to_voicemail(user1, user2, voicemail):
    response = confd.users(
        user1['id']).voicemail.post(voicemail_id=voicemail['id'])
    response.assert_created('users', 'voicemail')

    response = confd.users(
        user2['id']).voicemail.post(voicemail_id=voicemail['id'])
    response.assert_created('users', 'voicemail')
예제 #3
0
    def test_get_errors(self):
        fake_user = confd.users(FAKE_ID).funckeys.get
        fake_user_2 = confd.users(FAKE_ID).funckeys(1).get
        fake_funckey = confd.users(self.user['uuid']).funckeys(FAKE_ID).get

        s.check_resource_not_found(fake_user, 'User')
        s.check_resource_not_found(fake_user_2, 'User')
        s.check_resource_not_found(fake_funckey, 'FuncKey')
예제 #4
0
def test_delete_call_permission_when_user_and_call_permission_associated(
        user, call_permission):
    with a.user_call_permission(user, call_permission, check=False):
        response = confd.users(user['id']).callpermissions.get()
        assert_that(response.items, not_(empty()))
        confd.callpermissions(call_permission['id']).delete().assert_deleted()
        response = confd.users(user['id']).callpermissions.get()
        assert_that(response.items, empty())
예제 #5
0
def test_delete_user_when_user_and_call_permission_associated(
        user, call_permission):
    with a.user_call_permission(user, call_permission, check=False):
        response = confd.users(user['id']).callpermissions.get()
        assert_that(response.items, not_(empty()))
        confd.users(user['id']).delete().assert_deleted()
        invalid_user = confd.users(user['id']).callpermissions.get
        yield s.check_resource_not_found, invalid_user, 'User'
예제 #6
0
def test_delete_user_when_user_and_funckey_template_associated(
        user, funckey_template):
    with a.user_funckey_template(user, funckey_template, check=False):
        response = confd.funckeys.templates(funckey_template['id']).users.get()
        assert_that(response.items, not_(empty()))
        confd.users(user['id']).delete().assert_deleted()
        response = confd.funckeys.templates(funckey_template['id']).users.get()
        assert_that(response.items, empty())
예제 #7
0
def test_dissociate_second_user_then_first(first_user, second_user, line):
    with a.user_line(first_user, line, check=False), \
            a.user_line(second_user, line, check=False):
        response = confd.users(second_user['id']).lines(line['id']).delete()
        response.assert_deleted()

        response = confd.users(first_user['id']).lines(line['id']).delete()
        response.assert_deleted()
예제 #8
0
    def test_get_template_after_dissociation(self):
        self.association_url.put().assert_updated()
        self.association_url.delete().assert_deleted()

        response = confd.users(self.user['id']).funckeys.templates.get()
        assert_that(response.items, empty())

        response = confd.users(self.user['uuid']).funckeys.templates.get()
        assert_that(response.items, empty())
예제 #9
0
def test_get_call_permission_after_dissociation(user, call_permission):
    h.user_call_permission.associate(user['id'], call_permission['id'])
    h.user_call_permission.dissociate(user['id'], call_permission['id'])

    response = confd.users(user['id']).callpermissions.get()
    assert_that(response.items, empty())

    response = confd.users(user['uuid']).callpermissions.get()
    assert_that(response.items, empty())
예제 #10
0
def test_that_users_can_be_edited_by_uuid(user):
    response = confd.users(user['uuid']).put({
        'firstname': 'Fôo',
        'lastname': 'Bâr'
    })
    response.assert_updated()

    response = confd.users(user['uuid']).get()
    assert_that(response.item, has_entries(firstname='Fôo', lastname='Bâr'))
예제 #11
0
def test_get_user_voicemail_after_dissociation(user, voicemail):
    h.user_voicemail.associate(user['id'], voicemail['id'])
    h.user_voicemail.dissociate(user['id'], voicemail['id'])

    response = confd.users(user['id']).voicemail.get()
    response.assert_match(404, e.not_found('UserVoicemail'))

    response = confd.users(user['uuid']).voicemail.get()
    response.assert_match(404, e.not_found('UserVoicemail'))
예제 #12
0
def test_associate_muliple_users_to_line(user1, user2, user3, line):
    response = confd.users(user1['id']).lines.post(line_id=line['id'])
    response.assert_created('users', 'lines')

    response = confd.users(user2['id']).lines.post(line_id=line['id'])
    response.assert_created('users', 'lines')

    response = confd.users(user3['id']).lines.post(line_id=line['id'])
    response.assert_created('users', 'lines')
예제 #13
0
def test_get_line_after_dissociation(user, line):
    h.user_line.associate(user['id'], line['id'])
    h.user_line.dissociate(user['id'], line['id'])

    response = confd.users(user['id']).lines.get()
    assert_that(response.items, empty())

    response = confd.users(user['uuid']).lines.get()
    assert_that(response.items, empty())
예제 #14
0
    def setUp(self):
        super(TestUserWithFuncKey, self).setUp()

        self.destination = {'type': 'custom', 'exten': '1234'}
        self.pos = '1'

        self.funckey_url = confd.users(self.user['id']).funckeys(self.pos)
        self.uuid_url = confd.users(self.user['uuid']).funckeys(self.pos)

        self.funckey_url.put(destination=self.destination).assert_ok()
예제 #15
0
def test_dissociate_errors(user, call_permission):
    fake_user_call_permission = confd.users(user['id']).callpermissions(
        call_permission['id']).delete
    fake_user = confd.users(FAKE_ID).callpermissions(
        call_permission['id']).delete
    fake_call_permission = confd.users(
        user['id']).callpermissions(FAKE_ID).delete

    yield s.check_resource_not_found, fake_user, 'User'
    yield s.check_resource_not_found, fake_call_permission, 'CallPermission'
    yield s.check_resource_not_found, fake_user_call_permission, 'UserCallPermission'
예제 #16
0
def test_associating_two_sccp_lines_with_users_does_not_make_the_db_fail(
        user1, user2, line1, line2, sccp1, sccp2):
    with a.line_endpoint_sccp(line1, sccp1,
                              check=False), a.line_endpoint_sccp(line2,
                                                                 sccp2,
                                                                 check=False):
        response = confd.users(user1['id']).lines.post(line_id=line1['id'])
        response.assert_ok()

        response = confd.users(user2['id']).lines.post(line_id=line2['id'])
        response.assert_ok()
예제 #17
0
def test_get_line_associated_to_user(user, line):
    expected = contains(has_entries({'user_id': user['id'],
                                     'line_id': line['id'],
                                     'main_user': True,
                                     'main_line': True}))

    with a.user_line(user, line):
        response = confd.users(user['id']).lines.get()
        assert_that(response.items, expected)

        response = confd.users(user['uuid']).lines.get()
        assert_that(response.items, expected)
예제 #18
0
def test_get_user_voicemail_association(user, voicemail):
    expected = has_entries({
        'user_id': user['id'],
        'voicemail_id': voicemail['id']
    })

    with a.user_voicemail(user, voicemail):
        response = confd.users(user['id']).voicemail.get()
        assert_that(response.item, expected)

        response = confd.users(user['uuid']).voicemail.get()
        assert_that(response.item, expected)
예제 #19
0
def test_post_errors():
    empty_post = confd.users.post
    user_post = confd.users(firstname="Jôhn").post

    yield s.check_missing_required_field_returns_error, empty_post, 'firstname'
    for check in error_checks(user_post):
        yield check
예제 #20
0
def test_put_errors(user):
    user_put = confd.users(user['id']).put

    for check in error_checks(user_put):
        yield check
    for check in put_error_checks(user_put):
        yield check
예제 #21
0
def test_associate_extension_then_line_then_user(user, line, extension):
    response = confd.lines(
        line['id']).extensions.post(extension_id=extension['id'])
    response.assert_created('lines', 'extensions')

    response = confd.users(user['id']).lines.post(line_id=line['id'])
    response.assert_created('users', 'lines')
예제 #22
0
    def test_when_line_has_another_position_then_func_key_generated(self):
        user = helpers.user.generate_user()
        sip = helpers.endpoint_sip.generate_sip()
        line = helpers.line.generate_line(position=2)
        extension = helpers.extension.generate_extension()
        device = helpers.device.generate_device()

        helpers.line_endpoint_sip.associate(line['id'], sip['id'])
        helpers.line_extension.associate(line['id'], extension['id'])
        helpers.user_line.associate(user['id'], line['id'])
        helpers.line_device.associate(line['id'], device['id'])

        url = confd.users(user['id']).funckeys(self.pos)
        url.put(destination=self.destination).assert_ok()

        expected_funckey = {'label': None, 'inherited': False, 'blf': True}
        expected_destination = {
            'type': self.destination['type'],
            'exten': self.destination['exten'],
            'href': None
        }

        response = url.get()
        assert_that(response.item, has_entries(expected_funckey))
        assert_that(response.item['destination'],
                    has_entries(expected_destination))
예제 #23
0
def test_get_user_cti_profile_when_not_associated(user):
    response = confd.users(user['id']).cti.get()

    response.assert_link('users')
    assert_that(
        response.item,
        has_entries(user_id=user['id'], cti_profile_id=None, enabled=False))
예제 #24
0
def test_get_user_voicemail_association(user, voicemail):
    expected = has_entries({'user_id': user['id'],
                            'voicemail_id': voicemail['id']})

    with user_and_voicemail_associated(user, voicemail):
        response = confd.users(user['id']).voicemail.get()
        assert_that(response.item, expected)
예제 #25
0
def test_dissociate_user_line_when_device_is_associated(
        user, line, extension, device):
    with a.user_line(user, line), a.line_extension(line,
                                                   extension), a.line_device(
                                                       line, device):
        response = confd.users(user['id']).lines(line['id']).delete()
        response.assert_match(400, e.resource_associated('Line', 'Device'))
예제 #26
0
def test_associate_when_user_already_associated_to_same_call_permission(
        user, call_permission):
    with a.user_call_permission(user, call_permission):
        response = confd.users(user['id']).callpermissions(
            call_permission['id']).put()
        response.assert_match(400,
                              e.resource_associated('User', 'CallPermission'))
예제 #27
0
    def test_given_template_associated_when_getting_func_key_then_fetches_from_unified_template(self):
        self.association_url.put().assert_ok()

        response = confd.users(self.user['id']).funckeys(1).get()

        expected_destination = self.funckeys['1']['destination']
        assert_that(response.item, has_entry('inherited', True))
        assert_that(response.item['destination'], has_entries(expected_destination))
예제 #28
0
    def setUp(self):
        super(TestUserWithFuncKey, self).setUp()

        self.destination = {'type': 'custom', 'exten': '1234'}
        self.pos = '1'

        self.funckey_url = confd.users(self.user['id']).funckeys(self.pos)
        self.funckey_url.put(destination=self.destination).assert_ok()
예제 #29
0
def test_update_user_with_all_parameters(user):
    user_url = confd.users(user['id'])

    response = user_url.put(**FULL_USER)
    response.assert_updated()

    response = user_url.get()
    assert_that(response.item, has_entries(FULL_USER))
예제 #30
0
    def test_get_user_funckeys(self):
        destination_2 = {'type': 'custom', 'exten': '456'}
        destination_3 = {'type': 'custom', 'exten': '789'}
        destination_4 = {'type': 'custom', 'exten': '012'}
        confd.users(self.user['id']).funckeys(2).put(destination=destination_2)
        confd.users(self.user['id']).funckeys(3).put(destination=destination_3)
        template_parameters = {
            'name': 'pos4',
            'keys': {
                '4': {
                    'destination': destination_4
                }
            }
        }
        template = confd.funckeys.templates.post(**template_parameters).item
        confd.users(self.user['id']).funckeys.templates(template['id']).put()

        response = confd.users(self.user['id']).funckeys.get()

        expected_result = has_entries({
            'keys':
            has_entries({
                '1':
                has_entries({'destination': has_entries(self.destination)}),
                '2':
                has_entries({'destination': has_entries(destination_2)}),
                '3':
                has_entries({'destination': has_entries(destination_3)}),
                '4':
                has_entries({'destination': has_entries(destination_4)})
            })
        })

        assert_that(response.item, expected_result)
예제 #31
0
    def test_given_template_associated_when_getting_association_then_user_associated(self):
        self.association_url.put().assert_ok()

        response = confd.users(self.user['id']).funckeys.templates.get()

        expected_association = {'user_id': self.user['id'],
                                'template_id': self.template['id']}

        assert_that(response.items, contains(has_entries(expected_association)))
예제 #32
0
def test_get_call_permissions_associated_to_user(user, perm1, perm2):
    expected = contains(
        has_entries({
            'user_id': user['id'],
            'call_permission_id': perm1['id']
        }),
        has_entries({
            'user_id': user['id'],
            'call_permission_id': perm2['id']
        }))

    with a.user_call_permission(user, perm1):
        with a.user_call_permission(user, perm2):
            response = confd.users(user['id']).callpermissions.get()
            assert_that(response.items, expected)

            response = confd.users(user['uuid']).callpermissions.get()
            assert_that(response.items, expected)
예제 #33
0
def test_dissociate_extension_then_line_then_user(user, line, extension):
    with a.user_line(user, line, check=False), a.line_extension(line,
                                                                extension,
                                                                check=False):

        response = confd.lines(line['id']).extensions(extension['id']).delete()
        response.assert_deleted()

        response = confd.users(user['id']).lines(line['id']).delete()
        response.assert_deleted()
예제 #34
0
    def test_given_template_associated_when_getting_func_key_using_uuid_then_fetches_from_unified_template(
            self):
        self.uuid_url.put().assert_updated()

        response = confd.users(self.user['uuid']).funckeys(1).get()

        expected_destination = self.funckeys['1']['destination']
        assert_that(response.item, has_entry('inherited', True))
        assert_that(response.item['destination'],
                    has_entries(expected_destination))
예제 #35
0
    def setUp(self):
        super(TestTemplateAssociation, self).setUp()

        self.funckeys = {'1': {'destination': {'type': 'custom', 'exten': '9999'}},
                         '2': {'destination': {'type': 'parking'}}}

        self.provd_funckeys = {
            '1': {'label': '', 'type': 'blf', 'line': 1, 'value': '9999'},
            '2': {'label': '', 'type': 'park', 'line': 1, 'value': '700'}
        }

        response = confd.funckeys.templates.post(keys=self.funckeys)
        self.template = response.item

        self.association_url = confd.users(self.user['id']).funckeys.templates(self.template['id'])
예제 #36
0
    def test_given_user_has_funckey_when_template_associated_then_funckeys_merged(self):
        second_funckey = {'destination': {'type': 'user', 'user_id': self.user['id']}}
        third_funckey = {'destination': {'type': 'service', 'service': 'phonestatus'}}

        first_provd_funckey = self.provd_funckeys['1']
        second_provd_funckey = {'label': '', 'type': 'blf', 'line': 1, 'value': '1000'}
        third_provd_fundkey = {'label': '', 'type': 'speeddial', 'line': 1, 'value': '*10'}

        with confd.users(self.user['id']).funckeys as url:
            url(2).put(**second_funckey).assert_ok()
            url(3).put(**third_funckey).assert_ok()

        self.association_url.put().assert_ok()

        self.check_provd_has_funckey('1', first_provd_funckey)
        self.check_provd_has_funckey('2', second_provd_funckey)
        self.check_provd_has_funckey('3', third_provd_fundkey)
예제 #37
0
 def dissociate_resources(self, user_id, voicemail_id):
     return confd.users(user_id).voicemail.delete()
예제 #38
0
 def get_association(self, user_id, voicemail_id):
     return confd.users(user_id).voicemail.get()
예제 #39
0
def test_dissociate_second_user_before_first(first_user, second_user, line):
    with user_and_line_associated(first_user, line), user_and_line_associated(second_user, line):
        response = confd.users(first_user['id']).lines(line['id']).delete()
        response.assert_match(400, secondary_user_regex)
예제 #40
0
def test_delete_user_when_still_associated(user, voicemail):
    with user_and_voicemail_associated(user, voicemail):
        response = confd.users(user['id']).delete()
        response.assert_match(400, e.resource_associated('User', 'Voicemail'))
예제 #41
0
def test_associate_user_with_fake_cti_profile(user):
    url = confd.users(user['id']).cti
    response = url.put(cti_profile_id=FAKE_ID)
    response.assert_match(400, e.not_found('CtiProfile'))
예제 #42
0
def user_and_voicemail_associated(user, voicemail):
    response = confd.users(user['id']).voicemail.post(voicemail_id=voicemail['id'])
    response.assert_ok()
    yield
    confd.users(user['id']).voicemail.delete()
예제 #43
0
파일: user.py 프로젝트: litnimax/xivo-confd
def delete_user(user_id, check=False):
    response = confd.users(user_id).delete()
    if check:
        response.assert_ok()
예제 #44
0
def associate(user_id, line_id):
    response = confd.users(user_id).lines.post(line_id=line_id)
    response.assert_ok()
예제 #45
0
def dissociate(user_id, line_id):
    response = confd.users(user_id).lines(line_id).delete()
    response.assert_ok()
예제 #46
0
 def associate_resources(self, user_id, line_id):
     return confd.users(user_id).lines.post(line_id=line_id)
예제 #47
0
 def get_association(self, user_id, line_id):
     return confd.users(user_id).lines.get()
예제 #48
0
def test_associate_when_user_already_associated_to_another_line(user, first_line, second_line):
    with user_and_line_associated(user, first_line):
        response = confd.users(user['id']).lines.post(line_id=first_line['id'])
        response.assert_match(400, e.resource_associated('User', 'Line'))
예제 #49
0
def test_dissociate(user, voicemail):
    with user_and_voicemail_associated(user, voicemail):
        response = confd.users(user['id']).voicemail.delete()
        response.assert_ok()
예제 #50
0
 def associate_resources(self, user_id, voicemail_id):
     return confd.users(user_id).voicemail.post(voicemail_id=voicemail_id)
예제 #51
0
def test_get_when_not_associated(user):
    response = confd.users(user['id']).voicemail.get()
    response.assert_match(404, e.not_found('UserVoicemail'))
예제 #52
0
def test_get_when_user_does_not_exist():
    response = confd.users(FAKE_ID).cti.get()
    response.assert_match(404, e.not_found('User'))
예제 #53
0
def test_associate_multiple_users_to_voicemail(user1, user2, voicemail):
    response = confd.users(user1['id']).voicemail.post(voicemail_id=voicemail['id'])
    response.assert_ok()

    response = confd.users(user2['id']).voicemail.post(voicemail_id=voicemail['id'])
    response.assert_ok()
예제 #54
0
def test_enable_cti_for_user_without_username_or_password(user):
    url = confd.users(user['id']).cti
    response = url.put(enabled=True)
    response.assert_match(400, missing_username_password_regex)
예제 #55
0
def test_associate_when_already_associated(user, voicemail):
    with user_and_voicemail_associated(user, voicemail):
        response = confd.users(user['id']).voicemail.post(voicemail_id=voicemail['id'])
        response.assert_match(400, e.resource_associated('User', 'Voicemail'))
예제 #56
0
 def add_funckey_to_user(self, pos, funckey):
     response = confd.users(self.user['id']).funckeys(pos).put(**funckey)
     response.assert_ok()
예제 #57
0
def test_associate(user, voicemail):
    response = confd.users(user['id']).voicemail.post(voicemail_id=voicemail['id'])
    response.assert_ok()
예제 #58
0
 def dissociate_resources(self, user_id, line_id):
     return confd.users(user_id).lines(line_id).delete()
예제 #59
0
def test_delete_user_when_user_and_line_associated(user, line):
    with user_and_line_associated(user, line):
        response = confd.users(user['id']).delete()
        response.assert_match(400, e.resource_associated('User', 'Line'))