def test_access_to_unrestricted_file(self): # Requests of unrestricted files are redirected to Librarian URLs. request = LaunchpadTestRequest() request.setTraversalStack(['foo.txt']) navigation = BugAttachmentFileNavigation(self.bugattachment, request) view = navigation.publishTraverse(request, '+files') mo = re.match('^http://.*/\d+/foo.txt$', view.target) self.assertIsNot(None, mo)
def test_traversal_to_lfa_of_bug_attachment(self): # Traversing to the URL provided by a ProxiedLibraryFileAlias of a # bug attachament returns a RedirectionView. request = LaunchpadTestRequest() request.setTraversalStack(['foo.txt']) navigation = BugAttachmentFileNavigation(self.bugattachment, request) view = navigation.publishTraverse(request, '+files') self.assertIsInstance(view, RedirectionView)
def test_access_to_unrestricted_file(self): # Requests of unrestricted files are redirected to Librarian URLs. request = LaunchpadTestRequest() request.setTraversalStack(['foo.txt']) navigation = BugAttachmentFileNavigation( self.bugattachment, request) view = navigation.publishTraverse(request, '+files') mo = re.match('^http://.*/\d+/foo.txt$', view.target) self.assertIsNot(None, mo)
def test_traversal_to_lfa_of_bug_attachment(self): # Traversing to the URL provided by a ProxiedLibraryFileAlias of a # bug attachament returns a RedirectionView. request = LaunchpadTestRequest() request.setTraversalStack(['foo.txt']) navigation = BugAttachmentFileNavigation( self.bugattachment, request) view = navigation.publishTraverse(request, '+files') self.assertIsInstance(view, RedirectionView)
def test_access_to_restricted_file(self): # Requests of restricted files are redirected to librarian URLs # with tokens. lfa_with_parent = getMultiAdapter( (self.bugattachment.libraryfile, self.bugattachment), ILibraryFileAliasWithParent) lfa_with_parent.restricted = True self.bug.setPrivate(True, self.bug_owner) transaction.commit() request = LaunchpadTestRequest() request.setTraversalStack(['foo.txt']) navigation = BugAttachmentFileNavigation(self.bugattachment, request) view = navigation.publishTraverse(request, '+files') mo = re.match( '^https://.*.restricted.*/\d+/foo.txt\?token=.*$', view.target) self.assertIsNot(None, mo)
def test_access_to_restricted_file(self): # Requests of restricted files are redirected to librarian URLs # with tokens. lfa_with_parent = getMultiAdapter( (self.bugattachment.libraryfile, self.bugattachment), ILibraryFileAliasWithParent) lfa_with_parent.restricted = True self.bug.setPrivate(True, self.bug_owner) transaction.commit() request = LaunchpadTestRequest() request.setTraversalStack(['foo.txt']) navigation = BugAttachmentFileNavigation(self.bugattachment, request) view = navigation.publishTraverse(request, '+files') mo = re.match( '^https://.*.restricted.*/\d+/foo.txt\?token=.*$', view.target) self.assertIsNot(None, mo)