Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.Transport


  }

  @Test
  public void testListRemote_Dumb_Auth() throws Exception {
    Repository dst = createBareRepository();
    Transport t = Transport.open(dst, dumbAuthBasicURI);
    t.setCredentialsProvider(new UsernamePasswordCredentialsProvider(
        AppServer.username, AppServer.password));
    try {
      t.openFetch();
    } finally {
      t.close();
    }
    t = Transport.open(dst, dumbAuthBasicURI);
    t.setCredentialsProvider(new UsernamePasswordCredentialsProvider(
        AppServer.username, ""));
    try {
      t.openFetch();
      fail("connection opened even info/refs needs auth basic and we provide wrong password");
    } catch (TransportException err) {
      String exp = dumbAuthBasicURI + ": "
          + JGitText.get().notAuthorized;
      assertEquals(exp, err.getMessage());
    } finally {
      t.close();
    }
  }
View Full Code Here


  }

  @Test
  public void testListRemote_Smart_UploadPackNeedsAuth() throws Exception {
    Repository dst = createBareRepository();
    Transport t = Transport.open(dst, smartAuthBasicURI);
    try {
      try {
        t.openFetch();
        fail("connection opened even though service disabled");
      } catch (TransportException err) {
        String exp = smartAuthBasicURI + ": "
            + JGitText.get().notAuthorized;
        assertEquals(exp, err.getMessage());
      }
    } finally {
      t.close();
    }
  }
View Full Code Here

    final StoredConfig cfg = src.getConfig();
    cfg.setBoolean("http", null, "uploadpack", false);
    cfg.save();

    Repository dst = createBareRepository();
    Transport t = Transport.open(dst, smartAuthNoneURI);
    try {
      try {
        t.openFetch();
        fail("connection opened even though service disabled");
      } catch (TransportException err) {
        String exp = smartAuthNoneURI + ": Git access forbidden";
        assertEquals(exp, err.getMessage());
      }
    } finally {
      t.close();
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testListRemoteWithoutLocalRepository() throws Exception {
    Transport t = Transport.open(smartAuthNoneURI);
    try {
      FetchConnection c = t.openFetch();
      try {
        Ref head = c.getRef(Constants.HEAD);
        assertNotNull(head);
      } finally {
        c.close();
      }
    } finally {
      t.close();
    }
  }
View Full Code Here

    Repository dst = createBareRepository();

    assertEquals("http", remoteURI.getScheme());

    Map<String, Ref> map;
    Transport t = Transport.open(dst, remoteURI);
    ((TransportHttp) t).setUseSmartHttp(false);
    try {
      // I didn't make up these public interface names, I just
      // approved them for inclusion into the code base. Sorry.
      // --spearce
      //
      assertTrue("isa TransportHttp", t instanceof TransportHttp);
      assertTrue("isa HttpTransport", t instanceof HttpTransport);

      FetchConnection c = t.openFetch();
      try {
        map = c.getRefsMap();
      } finally {
        c.close();
      }
    } finally {
      t.close();
    }

    assertNotNull("have map of refs", map);
    assertEquals(2, map.size());
View Full Code Here

  @Test
  public void testInitialClone_Small() throws Exception {
    Repository dst = createBareRepository();
    assertFalse(dst.hasObject(A_txt));

    Transport t = Transport.open(dst, remoteURI);
    ((TransportHttp) t).setUseSmartHttp(false);
    try {
      t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
    } finally {
      t.close();
    }

    assertTrue(dst.hasObject(A_txt));
    assertEquals(B, dst.getRef(master).getObjectId());
    fsck(dst, B);
View Full Code Here

    new TestRepository<Repository>(remoteRepository).packAndPrune();

    Repository dst = createBareRepository();
    assertFalse(dst.hasObject(A_txt));

    Transport t = Transport.open(dst, remoteURI);
    ((TransportHttp) t).setUseSmartHttp(false);
    try {
      t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
    } finally {
      t.close();
    }

    assertTrue(dst.hasObject(A_txt));
    assertEquals(B, dst.getRef(master).getObjectId());
    fsck(dst, B);
View Full Code Here

  public void testPushNotSupported() throws Exception {
    final TestRepository src = createTestRepository();
    final RevCommit Q = src.commit().create();
    final Repository db = src.getRepository();

    Transport t = Transport.open(db, remoteURI);
    ((TransportHttp) t).setUseSmartHttp(false);
    try {
      try {
        t.push(NullProgressMonitor.INSTANCE, push(src, Q));
        fail("push incorrectly completed against a smart server");
      } catch (NotSupportedException nse) {
        String exp = "smart HTTP push disabled";
        assertEquals(exp, nse.getMessage());
      }
    } finally {
      t.close();
    }
  }
View Full Code Here

    final TestRepository src = createTestRepository();
    final RevBlob Q_txt = src.blob("new text");
    final RevCommit Q = src.commit().add("Q", Q_txt).create();
    final Repository db = src.getRepository();
    final String dstName = Constants.R_HEADS + "new.branch";
    Transport t;
    PushResult result;

    t = Transport.open(db, remoteURI);
    try {
      final String srcExpr = Q.name();
      final boolean forceUpdate = false;
      final String localName = null;
      final ObjectId oldId = null;

      RemoteRefUpdate update = new RemoteRefUpdate(src.getRepository(),
          srcExpr, dstName, forceUpdate, localName, oldId);
      result = t.push(NullProgressMonitor.INSTANCE, Collections
          .singleton(update));
    } finally {
      t.close();
    }

    assertTrue(remoteRepository.hasObject(Q_txt));
    assertNotNull("has " + dstName, remoteRepository.getRef(dstName));
    assertEquals(Q, remoteRepository.getRef(dstName).getObjectId());
View Full Code Here

    final TestRepository src = createTestRepository();
    final RevBlob Q_txt = src.blob("new text");
    final RevCommit Q = src.commit().add("Q", Q_txt).create();
    final Repository db = src.getRepository();
    final String dstName = Constants.R_HEADS + "new.branch";
    Transport t;
    PushResult result;

    t = Transport.open(db, remoteURI);
    OutputStream out = new ByteArrayOutputStream();
    try {
      final String srcExpr = Q.name();
      final boolean forceUpdate = false;
      final String localName = null;
      final ObjectId oldId = null;

      RemoteRefUpdate update = new RemoteRefUpdate(src.getRepository(),
          srcExpr, dstName, forceUpdate, localName, oldId);
      result = t.push(NullProgressMonitor.INSTANCE,
          Collections.singleton(update), out);
    } finally {
      t.close();
    }

    String expectedMessage = "message line 1\n" //
        + "error: no soup for you!\n" //
        + "come back next year!\n";
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.transport.Transport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.