Пример #1
0
    def test_get_shortlink__hierarchical_link_does_not_exist__subpath_exists(
            self):
        self.assertEqual((None, None),
                         helpers.get_shortlink('1.com', 'go', 'trotto'))

        self.assertEqual((None, None),
                         helpers.get_shortlink('1.com', 'go', 'trotto/fr'))
Пример #2
0
    def test_get_shortlink__same_shortlink_different_companies__alternate_namespace(
            self):
        self.assertEqual((ShortLink.get_by_id(117), 'https://1.drive.com/eng'),
                         helpers.get_shortlink('1.com', 'eng', 'drive'))

        self.assertEqual((ShortLink.get_by_id(118), 'https://2.drive.com/eng'),
                         helpers.get_shortlink('2.com', 'eng', 'drive'))
Пример #3
0
def get_go_link(path):
    requested_at = time.time()

    provided_shortpath = parse.unquote(path.strip('/'))
    shortpath_parts = provided_shortpath.split('/', 1)
    shortpath = '/'.join([shortpath_parts[0].lower()] + shortpath_parts[1:])

    if not getattr(current_user, 'email', None):
        if request.args.get('s') == 'crx' and request.args.get('sc'):
            # see: go/484356182846856
            return force_to_original_url()

        return redirect('/_/auth/login?%s' %
                        parse.urlencode({'redirect_to': request.full_path}))

    matching_shortlink, destination = get_shortlink(current_user.organization,
                                                    shortpath)

    if matching_shortlink:
        queue_event(requested_at, matching_shortlink.get_id(), destination,
                    request.args.get('s') or 'other')
        return redirect(str(destination))
    elif request.args.get('s') == 'crx' and request.args.get('sc'):
        return force_to_original_url()
    else:
        return redirect(
            '%s/?%s' %
            ('http://localhost:5007' if request.host.startswith('localhost')
             else '', parse.urlencode({'sp': shortpath})))
Пример #4
0
 def test_get_shortlink__go_link_with_placeholder(self):
     self.assertEqual((models.ShortLink.get_by_id(116),
                       'http://looker.com/7/search/users'),
                      helpers.get_shortlink('1.com', 'looker/7/users'))
Пример #5
0
 def test_get_shortlink__simple_go_link(self):
     self.assertEqual((models.ShortLink.get_by_id(14), 'http://drive4.com'),
                      helpers.get_shortlink('1.com', 'drive'))
Пример #6
0
 def test_get_shortlink__link_does_not_exist(self):
     self.assertEqual((None, None), helpers.get_shortlink('1.com', 'slack'))
Пример #7
0
 def test_get_shortlink__hierarchical_link_does_not_exist(self):
     self.assertEqual((None, None),
                      helpers.get_shortlink('1.com', 'go', 'trotto/jots'))
Пример #8
0
 def test_get_shortlink__hierarchical_link_exists_in_other_org(self):
     self.assertEqual((None, None),
                      helpers.get_shortlink('2.com', 'go', 'trotto/docs'))
Пример #9
0
    def test_get_shortlink__hierarchical_link_exists(self):
        self.assertEqual((ShortLink.get_by_id(16), 'http://www.trot.to/docs'),
                         helpers.get_shortlink('1.com', 'go', 'trotto/docs'))

        self.assertEqual((ShortLink.get_by_id(17), 'http://fr.trot.to'),
                         helpers.get_shortlink('1.com', 'go', 'trotto/fr/t'))