Exemple #1
0
 def test_dropbox_get_share_emails(self):
     # project has some contributors
     contrib = AuthUserFactory()
     self.project.add_contributor(contrib, auth=Auth(self.user))
     self.project.save()
     url = api_url_for('dropbox_get_share_emails', pid=self.project._primary_key)
     res = self.app.get(url, auth=self.user.auth)
     result = res.json['result']
     assert_equal(result['emails'], [u.username for u in self.project.contributors
                                     if u != self.user])
     assert_equal(result['url'], utils.get_share_folder_uri(self.node_settings.folder))
Exemple #2
0
    def test_serialize_settings_helper_returns_correct_urls(self):
        result = serialize_settings(self.node_settings, self.user, client=mock_client)
        urls = result['urls']

        assert_equal(urls['config'], self.project.api_url_for('dropbox_config_put'))
        assert_equal(urls['deauthorize'], self.project.api_url_for('dropbox_deauthorize'))
        assert_equal(urls['auth'], self.project.api_url_for('dropbox_oauth_start'))
        assert_equal(urls['importAuth'], self.project.api_url_for('dropbox_import_user_auth'))
        assert_equal(urls['files'], self.project.web_url_for('collect_file_trees'))
        assert_equal(urls['share'], utils.get_share_folder_uri(self.node_settings.folder))
        # Includes endpoint for fetching folders only
        # NOTE: Querystring params are in camelCase
        assert_equal(urls['folders'],
            self.project.api_url_for('dropbox_hgrid_data_contents', foldersOnly=1, includeRoot=1))
        assert_equal(urls['settings'], web_url_for('user_addons'))
Exemple #3
0
def dropbox_get_share_emails(auth, user_addon, node_addon, **kwargs):
    """Return a list of emails of the contributors on a project.

    The current user MUST be the user who authenticated Dropbox for the node.
    """
    if not node_addon.user_settings:
        raise HTTPError(http.BAD_REQUEST)
    # Current user must be the user who authorized the addon
    if node_addon.user_settings.owner != auth.user:
        raise HTTPError(http.FORBIDDEN)
    result = {
        'emails': [contrib.username
                    for contrib in node_addon.owner.contributors
                        if contrib != auth.user],
        'url': utils.get_share_folder_uri(node_addon.folder)
    }
    return {'result': result}, http.OK
Exemple #4
0
def serialize_urls(node_settings):
    node = node_settings.owner
    if node_settings.folder and node_settings.folder != '/':
        # The link to share a the folder with other Dropbox users
        share_url = utils.get_share_folder_uri(node_settings.folder)
    else:
        share_url = None

    urls = {
        'config': node.api_url_for('dropbox_config_put'),
        'deauthorize': node.api_url_for('dropbox_deauthorize'),
        'auth': node.api_url_for('dropbox_oauth_start'),
        'importAuth': node.api_url_for('dropbox_import_user_auth'),
        'files': node.web_url_for('collect_file_trees'),
        # Endpoint for fetching only folders (including root)
        'folders': node.api_url_for('dropbox_hgrid_data_contents', root=1),
        'share': share_url,
        'emails': node.api_url_for('dropbox_get_share_emails'),
        'settings': web_url_for('user_addons')
    }
    return urls
Exemple #5
0
def serialize_urls(node_settings):
    node = node_settings.owner
    if node_settings.folder and node_settings.folder != '/':
        # The link to share a the folder with other Dropbox users
        share_url = utils.get_share_folder_uri(node_settings.folder)
    else:
        share_url = None

    urls = {
        'config': node.api_url_for('dropbox_config_put'),
        'deauthorize': node.api_url_for('dropbox_deauthorize'),
        'auth': node.api_url_for('dropbox_oauth_start'),
        'importAuth': node.api_url_for('dropbox_import_user_auth'),
        'files': node.web_url_for('collect_file_trees'),
        # Endpoint for fetching only folders (including root)
        'folders': node.api_url_for('dropbox_hgrid_data_contents', root=1),
        'share': share_url,
        'emails': node.api_url_for('dropbox_get_share_emails'),
        'settings': web_url_for('user_addons')
    }
    return urls
Exemple #6
0
def test_get_share_folder_uri():
    expected = 'https://dropbox.com/home/foo?shareoptions=1&share_subfolder=0&share=1'
    assert_equal(utils.get_share_folder_uri('/foo/'), expected)
    assert_equal(utils.get_share_folder_uri('foo'), expected)
Exemple #7
0
def test_get_share_folder_uri():
    expected = 'https://dropbox.com/home/foo?shareoptions=1&share_subfolder=0&share=1'
    assert_equal(utils.get_share_folder_uri('/foo/'), expected)
    assert_equal(utils.get_share_folder_uri('foo'), expected)