def setUp(self):
     frontend = InMemoryFrontend()
     self.codehosting_api = frontend.getCodehostingEndpoint()
     self.factory = frontend.getLaunchpadObjectFactory()
     self.requester = self.factory.makePerson()
     self.server = self.getLaunchpadServer(self.codehosting_api,
                                           self.requester.id)
Esempio n. 2
0
 def setUp(self):
     super(TestBranchFileSystemClient, self).setUp()
     frontend = InMemoryFrontend()
     self.factory = frontend.getLaunchpadObjectFactory()
     self.user = self.factory.makePerson()
     self._xmlrpc_client = XMLRPCWrapper(frontend.getCodehostingEndpoint())
     self.fake_time = FakeTime(12345)
    def setUp(self):
        BzrTestCase.setUp(self)

        memory_server = self._setUpMemoryServer()
        memory_transport = get_transport(memory_server.get_url())
        backing_transport = memory_transport.clone('backing')

        self._frontend = InMemoryFrontend()
        self.factory = self._frontend.getLaunchpadObjectFactory()

        codehosting_api = self._frontend.getCodehostingEndpoint()
        self.requester = self.factory.makePerson()

        self.writable_branch = self.factory.makeAnyBranch(
            branch_type=BranchType.HOSTED, owner=self.requester).unique_name
        self.writable_file = '/%s/.bzr/hello.txt' % self.writable_branch
        self.read_only_branch = self.factory.makeAnyBranch(
            branch_type=BranchType.HOSTED).unique_name

        self.lp_server = self._setUpLaunchpadServer(self.requester.id,
                                                    codehosting_api,
                                                    backing_transport)
        self.lp_transport = get_transport(self.lp_server.get_url())
        self.lp_transport.mkdir(os.path.dirname(self.writable_file))
        self.lp_transport.put_bytes(self.writable_file, 'Hello World!')
 def setUp(self):
     super(TestBranchFileSystemClient, self).setUp()
     frontend = InMemoryFrontend()
     self.factory = frontend.getLaunchpadObjectFactory()
     self.user = self.factory.makePerson()
     self._xmlrpc_client = XMLRPCWrapper(frontend.getCodehostingEndpoint())
     self.fake_time = FakeTime(12345)
 def setUp(self):
     frontend = InMemoryFrontend()
     self.codehosting_api = frontend.getCodehostingEndpoint()
     self.factory = frontend.getLaunchpadObjectFactory()
     self.requester = self.factory.makePerson()
     self.server = self.getLaunchpadServer(
         self.codehosting_api, self.requester.id)
class TestLaunchpadTransportReadOnly(BzrTestCase):
    """Tests for read-only operations on the LaunchpadTransport."""

    run_tests_with = AsynchronousDeferredRunTest

    def setUp(self):
        BzrTestCase.setUp(self)

        memory_server = self._setUpMemoryServer()
        memory_transport = get_transport(memory_server.get_url())
        backing_transport = memory_transport.clone('backing')

        self._frontend = InMemoryFrontend()
        self.factory = self._frontend.getLaunchpadObjectFactory()

        codehosting_api = self._frontend.getCodehostingEndpoint()
        self.requester = self.factory.makePerson()

        self.writable_branch = self.factory.makeAnyBranch(
            branch_type=BranchType.HOSTED, owner=self.requester).unique_name
        self.writable_file = '/%s/.bzr/hello.txt' % self.writable_branch
        self.read_only_branch = self.factory.makeAnyBranch(
            branch_type=BranchType.HOSTED).unique_name

        self.lp_server = self._setUpLaunchpadServer(
            self.requester.id, codehosting_api, backing_transport)
        self.lp_transport = get_transport(self.lp_server.get_url())
        self.lp_transport.mkdir(os.path.dirname(self.writable_file))
        self.lp_transport.put_bytes(self.writable_file, 'Hello World!')

    def _setUpMemoryServer(self):
        memory_server = MemoryServer()
        memory_server.start_server()
        self.addCleanup(memory_server.stop_server)
        return memory_server

    def _setUpLaunchpadServer(self, user_id, codehosting_api,
                              backing_transport):
        server = LaunchpadServer(
            XMLRPCWrapper(codehosting_api), user_id, backing_transport)
        server.start_server()
        self.addCleanup(server.stop_server)
        return server

    def test_mkdir_readonly(self):
        # If we only have READ_ONLY access to a branch then we should not be
        # able to create directories within that branch.
        self.assertRaises(
            errors.TransportNotPossible,
            self.lp_transport.mkdir, '%s/.bzr' % self.read_only_branch)

    def test_rename_target_readonly(self):
        # Even if we can write to a file, we can't rename it to location which
        # is read-only to us.
        self.assertRaises(
            errors.TransportNotPossible,
            self.lp_transport.rename, self.writable_file,
            '/%s/.bzr/goodbye.txt' % self.read_only_branch)
class TestLaunchpadTransportReadOnly(BzrTestCase):
    """Tests for read-only operations on the LaunchpadTransport."""

    run_tests_with = AsynchronousDeferredRunTest

    def setUp(self):
        BzrTestCase.setUp(self)

        memory_server = self._setUpMemoryServer()
        memory_transport = get_transport(memory_server.get_url())
        backing_transport = memory_transport.clone('backing')

        self._frontend = InMemoryFrontend()
        self.factory = self._frontend.getLaunchpadObjectFactory()

        codehosting_api = self._frontend.getCodehostingEndpoint()
        self.requester = self.factory.makePerson()

        self.writable_branch = self.factory.makeAnyBranch(
            branch_type=BranchType.HOSTED, owner=self.requester).unique_name
        self.writable_file = '/%s/.bzr/hello.txt' % self.writable_branch
        self.read_only_branch = self.factory.makeAnyBranch(
            branch_type=BranchType.HOSTED).unique_name

        self.lp_server = self._setUpLaunchpadServer(self.requester.id,
                                                    codehosting_api,
                                                    backing_transport)
        self.lp_transport = get_transport(self.lp_server.get_url())
        self.lp_transport.mkdir(os.path.dirname(self.writable_file))
        self.lp_transport.put_bytes(self.writable_file, 'Hello World!')

    def _setUpMemoryServer(self):
        memory_server = MemoryServer()
        memory_server.start_server()
        self.addCleanup(memory_server.stop_server)
        return memory_server

    def _setUpLaunchpadServer(self, user_id, codehosting_api,
                              backing_transport):
        server = LaunchpadServer(XMLRPCWrapper(codehosting_api), user_id,
                                 backing_transport)
        server.start_server()
        self.addCleanup(server.stop_server)
        return server

    def test_mkdir_readonly(self):
        # If we only have READ_ONLY access to a branch then we should not be
        # able to create directories within that branch.
        self.assertRaises(errors.TransportNotPossible, self.lp_transport.mkdir,
                          '%s/.bzr' % self.read_only_branch)

    def test_rename_target_readonly(self):
        # Even if we can write to a file, we can't rename it to location which
        # is read-only to us.
        self.assertRaises(errors.TransportNotPossible,
                          self.lp_transport.rename, self.writable_file,
                          '/%s/.bzr/goodbye.txt' % self.read_only_branch)
 def setUp(self):
     frontend = InMemoryFrontend()
     self.factory = frontend.getLaunchpadObjectFactory()
     codehosting_api = frontend.getCodehostingEndpoint()
     self.requester = self.factory.makePerson()
     self.backing_transport = MemoryTransport()
     self.server = self.getServer(
         codehosting_api, self.requester.id, self.backing_transport)
     self.server.start_server()
     self.addCleanup(self.server.stop_server)
 def setUp(self):
     frontend = InMemoryFrontend()
     self.factory = frontend.getLaunchpadObjectFactory()
     codehosting_api = frontend.getCodehostingEndpoint()
     self.requester = self.factory.makePerson()
     self.backing_transport = MemoryTransport()
     self.server = self.getServer(codehosting_api, self.requester.id,
                                  self.backing_transport)
     self.server.start_server()
     self.addCleanup(self.server.stop_server)
Esempio n. 10
0
 def setUp(self):
     super(TestFilesystem, self).setUp()
     self.disable_directory_isolation()
     frontend = InMemoryFrontend()
     self.factory = frontend.getLaunchpadObjectFactory()
     endpoint = XMLRPCWrapper(frontend.getCodehostingEndpoint())
     self.requester = self.factory.makePerson()
     self._server = LaunchpadServer(
         endpoint, self.requester.id, MemoryTransport())
     self._server.start_server()
     self.addCleanup(self._server.stop_server)
 def setUp(self):
     super(TestFilesystem, self).setUp()
     self.disable_directory_isolation()
     frontend = InMemoryFrontend()
     self.factory = frontend.getLaunchpadObjectFactory()
     endpoint = XMLRPCWrapper(frontend.getCodehostingEndpoint())
     self.requester = self.factory.makePerson()
     self._server = LaunchpadServer(
         endpoint, self.requester.id, MemoryTransport())
     self._server.start_server()
     self.addCleanup(self._server.stop_server)
Esempio n. 12
0
 def setUp(self):
     super(TestBranchChangedNotification, self).setUp()
     self._server = None
     self._branch_changed_log = []
     frontend = InMemoryFrontend()
     self.factory = frontend.getLaunchpadObjectFactory()
     self.codehosting_api = frontend.getCodehostingEndpoint()
     self.codehosting_api.branchChanged = self._replacement_branchChanged
     self.requester = self.factory.makePerson()
     self.backing_transport = MemoryTransport()
     self.disable_directory_isolation()
Esempio n. 13
0
 def setUp(self):
     super(TestBranchChangedNotification, self).setUp()
     self._server = None
     self._branch_changed_log = []
     frontend = InMemoryFrontend()
     self.factory = frontend.getLaunchpadObjectFactory()
     self.codehosting_api = frontend.getCodehostingEndpoint()
     self.codehosting_api.branchChanged = self._replacement_branchChanged
     self.requester = self.factory.makePerson()
     self.backing_transport = MemoryTransport()
     self.disable_directory_isolation()
Esempio n. 14
0
    def setUp(self):
        super(TestBranchChangedErrorHandling, self).setUp()
        self._server = None
        frontend = InMemoryFrontend()
        self.factory = frontend.getLaunchpadObjectFactory()
        self.codehosting_api = frontend.getCodehostingEndpoint()
        self.codehosting_api.branchChanged = self._replacement_branchChanged
        self.requester = self.factory.makePerson()
        self.backing_transport = MemoryTransport()
        self.disable_directory_isolation()

        # Trap stderr.
        self.addCleanup(setattr, sys, 'stderr', sys.stderr)
        self._real_stderr = sys.stderr
        sys.stderr = codecs.getwriter('utf8')(StringIO())

        # To record generated oopsids
        self.generated_oopsids = []
Esempio n. 15
0
    def __init__(self):
        """Initialize the server.

        We register ourselves with the scheme lp-testing=${id(self)}:/// using
        an in-memory XML-RPC client and backed onto a LocalTransport.
        """
        frontend = InMemoryFrontend()
        branchfs = frontend.getCodehostingEndpoint()
        branch = frontend.getLaunchpadObjectFactory().makeAnyBranch()
        self._branch_path = branch.unique_name
        # XXX: JonathanLange bug=276972 2008-10-07: This should back on to a
        # MemoryTransport, but a bug in Bazaar's implementation makes it
        # unreliable for tests that involve particular errors.
        LaunchpadInternalServer.__init__(
            self, 'lp-testing-%s:///' % id(self),
            DeferredBlockingProxy(branchfs),
            LocalTransport(local_path_to_url('.')))
        self._chroot_servers = []
Esempio n. 16
0
    def __init__(self):
        """Initialize the server.

        We register ourselves with the scheme lp-testing=${id(self)}:/// using
        an in-memory XML-RPC client and backed onto a LocalTransport.
        """
        frontend = InMemoryFrontend()
        branchfs = frontend.getCodehostingEndpoint()
        branch = frontend.getLaunchpadObjectFactory().makeAnyBranch()
        self._branch_path = branch.unique_name
        # XXX: JonathanLange bug=276972 2008-10-07: This should back on to a
        # MemoryTransport, but a bug in Bazaar's implementation makes it
        # unreliable for tests that involve particular errors.
        LaunchpadInternalServer.__init__(
            self, 'lp-testing-%s:///' % id(self),
            DeferredBlockingProxy(branchfs),
            LocalTransport(local_path_to_url('.')))
        self._chroot_servers = []
Esempio n. 17
0
    def setUp(self):
        super(TestBranchChangedErrorHandling, self).setUp()
        self._server = None
        frontend = InMemoryFrontend()
        self.factory = frontend.getLaunchpadObjectFactory()
        self.codehosting_api = frontend.getCodehostingEndpoint()
        self.codehosting_api.branchChanged = self._replacement_branchChanged
        self.requester = self.factory.makePerson()
        self.backing_transport = MemoryTransport()
        self.disable_directory_isolation()

        # Trap stderr.
        self.addCleanup(setattr, sys, 'stderr', sys.stderr)
        self._real_stderr = sys.stderr
        sys.stderr = codecs.getwriter('utf8')(StringIO())

        # To record generated oopsids
        self.generated_oopsids = []
Esempio n. 18
0
    def setUp(self):
        BzrTestCase.setUp(self)

        memory_server = self._setUpMemoryServer()
        memory_transport = get_transport(memory_server.get_url())
        backing_transport = memory_transport.clone('backing')

        self._frontend = InMemoryFrontend()
        self.factory = self._frontend.getLaunchpadObjectFactory()

        codehosting_api = self._frontend.getCodehostingEndpoint()
        self.requester = self.factory.makePerson()

        self.writable_branch = self.factory.makeAnyBranch(
            branch_type=BranchType.HOSTED, owner=self.requester).unique_name
        self.writable_file = '/%s/.bzr/hello.txt' % self.writable_branch
        self.read_only_branch = self.factory.makeAnyBranch(
            branch_type=BranchType.HOSTED).unique_name

        self.lp_server = self._setUpLaunchpadServer(
            self.requester.id, codehosting_api, backing_transport)
        self.lp_transport = get_transport(self.lp_server.get_url())
        self.lp_transport.mkdir(os.path.dirname(self.writable_file))
        self.lp_transport.put_bytes(self.writable_file, 'Hello World!')
Esempio n. 19
0
 def setUp(self):
     TestCase.setUp(self)
     frontend = InMemoryFrontend()
     self.factory = frontend.getLaunchpadObjectFactory()
     self.codehosting_endpoint = XMLRPCWrapper(
         frontend.getCodehostingEndpoint())
Esempio n. 20
0
 def setUp(self):
     TestCase.setUp(self)
     frontend = InMemoryFrontend()
     self.factory = frontend.getLaunchpadObjectFactory()
     self.codehosting_endpoint = XMLRPCWrapper(
         frontend.getCodehostingEndpoint())