@Test
  public void autoDiscoverWithOneCompleteLocationFromMirrorWithEncryptedPassword()
      throws NexusDiscoveryException {
    Settings settings = new Settings();

    String url = "http://nexus.somewhere.com/";

    testClientManager.testUrl = url;
    testClientManager.testUser = "******";
    testClientManager.testPassword = "******";

    Mirror mirror = new Mirror();
    mirror.setId("some-mirror");
    mirror.setName("A Mirror");
    mirror.setUrl(url);

    settings.addMirror(mirror);

    Server server = new Server();
    server.setId("some-mirror");
    server.setUsername("user");
    server.setPassword(encryptedPassword);

    settings.addServer(server);

    Model model = new Model();
    model.setModelVersion("4.0.0");
    model.setGroupId("group.id");
    model.setArtifactId("artifact-id");
    model.setVersion("1");

    MavenProject project = new MavenProject(model);

    discovery.discover(settings, project, "blah", true);
  }
  @Test
  public void promptWithTwoPotentialLocationsFromMirrors() throws NexusDiscoveryException {
    Settings settings = new Settings();

    String url = "http://nexus.somewhere.com/";
    String user = "******";
    String password = "******";

    testClientManager.testUrl = url;
    testClientManager.testUser = user;
    testClientManager.testPassword = password;

    Mirror mirror = new Mirror();
    mirror.setId("some-mirror");
    mirror.setName("A Mirror");
    mirror.setUrl(url);

    settings.addMirror(mirror);

    Mirror mirror2 = new Mirror();
    mirror2.setId("some-other-mirror");
    mirror2.setName("Another Mirror");
    mirror2.setUrl("http://nexus.somewhere-else.com/");

    settings.addMirror(mirror2);

    Model model = new Model();
    model.setModelVersion("4.0.0");
    model.setGroupId("group.id");
    model.setArtifactId("artifact-id");
    model.setVersion("1");

    MavenProject project = new MavenProject(model);

    prompter.addExpectation("1", "http://nexus.somewhere.com/", "Selection:");
    prompter.addExpectation("Enter Username", user);
    prompter.addExpectation("Enter Password", password);

    NexusConnectionInfo info = discovery.discover(settings, project, "blah", false);
    assertNotNull(info);
    assertEquals(url, info.getNexusUrl());
    assertEquals(user, info.getUser());
    assertEquals(password, info.getPassword());
  }
Пример #3
0
 private Mirror getMirror(RepositorySystemSession session, ArtifactRepository repository) {
   if (session != null) {
     org.eclipse.aether.repository.MirrorSelector selector = session.getMirrorSelector();
     if (selector != null) {
       RemoteRepository repo = selector.getMirror(RepositoryUtils.toRepo(repository));
       if (repo != null) {
         Mirror mirror = new Mirror();
         mirror.setId(repo.getId());
         mirror.setUrl(repo.getUrl());
         mirror.setLayout(repo.getContentType());
         return mirror;
       }
     }
   }
   return null;
 }