Exemple #1
0
    def test_get_default_not_found(self):
        clients_manager = ClientsManager({'tracker.org': ClientCollectionTest.TestClient()})
        clients_manager.default_client = None

        client = DefaultClient(clients_manager)
        client.__no_auth__ = True
        self.api.add_route('/api/default_client', client)

        body = self.simulate_request('/api/default_client', decode="utf-8")
        self.assertEqual(self.srmock.status, falcon.HTTP_NOT_FOUND)
    def test_get_default_not_found(self):
        clients_manager = ClientsManager({'tracker.org': ClientCollectionTest.TestClient()})
        clients_manager.default_client = None

        client = DefaultClient(clients_manager)
        client.__no_auth__ = True
        self.api.add_route('/api/default_client', client)

        body = self.simulate_request('/api/default_client', decode="utf-8")
        self.assertEqual(self.srmock.status, falcon.HTTP_NOT_FOUND)
Exemple #3
0
    def test_get_default(self):
        clients_manager = ClientsManager({'tracker.org': ClientCollectionTest.TestClient()})

        client = DefaultClient(clients_manager)
        client.__no_auth__ = True
        self.api.add_route('/api/default_client', client)

        body = self.simulate_request('/api/default_client', decode="utf-8")
        self.assertEqual(self.srmock.status, falcon.HTTP_OK)

        result = json.loads(body)

        assert result == {'name': 'test_client', 'settings': {}, 'fields': {}}
    def test_get_default(self):
        clients_manager = ClientsManager({'tracker.org': ClientCollectionTest.TestClient()})

        client = DefaultClient(clients_manager)
        client.__no_auth__ = True
        self.api.add_route('/api/default_client', client)

        body = self.simulate_request('/api/default_client', decode="utf-8")
        self.assertEqual(self.srmock.status, falcon.HTTP_OK)

        result = json.loads(body)

        self.assertEqual(result, {'name': 'test_client', 'settings': {}, 'fields': []})
Exemple #5
0
    def test_get_default_with_fields(self):
        clients_manager = ClientsManager({'tracker.org': self.TestClientWithFields()})

        client = DefaultClient(clients_manager)
        client.__no_auth__ = True
        self.api.add_route('/api/default_client', client)

        body = self.simulate_request('/api/default_client', decode="utf-8")
        self.assertEqual(self.srmock.status, falcon.HTTP_OK)

        result = json.loads(body)

        expected_fields = {
            'download_dir': u'/mnt/media/download',
            'other': None
        }
        assert result == {'name': 'test_client_with_fields', 'settings': {}, 'fields': expected_fields}
Exemple #6
0
def create_app(secret_key, token, tracker_manager, clients_manager,
               notifier_manager, settings_manager, engine_runner, log_manager,
               new_version_checker, log):
    AuthMiddleware.init(
        secret_key, token,
        lambda: settings_manager.get_is_authentication_enabled())
    app = create_api()
    add_static_route(app, 'webapp', log)
    app.add_route('/api/login', Login(settings_manager))
    app.add_route('/api/logout', Logout())
    app.add_route('/api/topics', TopicCollection(tracker_manager))
    app.add_route('/api/topics/{id}', Topic(tracker_manager))
    app.add_route('/api/topics/{id}/reset_status',
                  TopicResetStatus(tracker_manager))
    app.add_route('/api/topics/{id}/pause', TopicPauseState(tracker_manager))
    app.add_route('/api/topics/parse', TopicParse(tracker_manager))
    app.add_route('/api/trackers', TrackerCollection(tracker_manager))
    app.add_route('/api/trackers/{tracker}', Tracker(tracker_manager))
    app.add_route('/api/trackers/{tracker}/check',
                  TrackerCheck(tracker_manager))
    app.add_route('/api/default_client', DefaultClient(clients_manager))
    app.add_route('/api/clients', ClientCollection(clients_manager))
    app.add_route('/api/clients/{client}', Client(clients_manager))
    app.add_route('/api/clients/{client}/check', ClientCheck(clients_manager))
    app.add_route('/api/clients/{client}/default',
                  ClientDefault(clients_manager))
    app.add_route('/api/notifiers', NotifierCollection(notifier_manager))
    app.add_route('/api/notifiers/{notifier}', Notifier(notifier_manager))
    app.add_route('/api/notifiers/{notifier}/check',
                  NotifierCheck(notifier_manager))
    app.add_route('/api/notifiers/{notifier}/enabled',
                  NotifierEnabled(notifier_manager))
    app.add_route('/api/settings/authentication',
                  SettingsAuthentication(settings_manager))
    app.add_route('/api/settings/password', SettingsPassword(settings_manager))
    app.add_route('/api/settings/developer',
                  SettingsDeveloper(settings_manager))
    app.add_route('/api/settings/logs', SettingsLogs(settings_manager))
    app.add_route('/api/settings/proxy/enabled',
                  SettingsProxyEnabled(settings_manager))
    app.add_route('/api/settings/proxy', SettingsProxy(settings_manager))
    app.add_route('/api/settings/execute', SettingsExecute(engine_runner))
    app.add_route(
        '/api/settings/new-version-checker',
        SettingsNewVersionChecker(settings_manager, new_version_checker))
    app.add_route('/api/settings/notify-on',
                  SettingsNotifyOn(settings_manager))
    app.add_route('/api/new-version', NewVersion(new_version_checker))
    app.add_route('/api/execute/logs', ExecuteLogs(log_manager))
    app.add_route('/api/execute/logs/{execute_id}/details',
                  ExecuteLogsDetails(log_manager))
    app.add_route('/api/execute/logs/current', ExecuteLogCurrent(log_manager))
    app.add_route('/api/execute/call', ExecuteCall(engine_runner))
    return app