Skip to content
Browse files

[maven-release-plugin] copy for tag nexus-migration-plugin-1.1.0

git-svn-id: file:///opt/svn/repositories/sonatype.org/nexus-plugins/tags/nexus-migration-plugin-1.1.0@362 c41184c3-3edd-4803-b646-023156917d6f
  • Loading branch information...
2 parents f4291a8 + 300ed72 commit 5f990c7599f2884e86bdc9852f3934ff5a3cd1db @dbradicich dbradicich committed Aug 19, 2009
View
9 ...main/java/org/sonatype/nexus/plugin/migration/artifactory/DefaultArtifactoryMigrator.java
@@ -293,10 +293,11 @@ private void importSecurity( MigrationResult result, ArtifactorySecurityConfig c
{
result.addInfoMessage( "Importing user: " + userResolution.getUserId() );
- ArtifactoryUser user =
- new ArtifactoryUser( userResolution.getUserId(), userResolution.getPassword(),
- userResolution.getEmail() );
+ ArtifactoryUser user = cfg.getUserByUsername( userResolution.getUserId() );
+ user.setUsername( userResolution.getUserId() );
+ user.setPassword( userResolution.getPassword() );
+ user.setEmail( userResolution.getEmail() );
user.setAdmin( userResolution.isAdmin() );
userList.add( user );
@@ -478,6 +479,8 @@ private Repository createRepository( ArtifactoryRepository repo, Map<String, Art
CRepository nexusRepo = new CRepository();
nexusRepo.setId( repoId );
nexusRepo.setName( repoName );
+ nexusRepo.setAllowWrite( true );
+
if ( isSnapshot )
{
nexusRepo.setRepositoryPolicy( CRepository.REPOSITORY_POLICY_SNAPSHOT );
View
18 ...a/org/sonatype/nexus/plugin/migration/artifactory/security/ArtifactorySecurityConfig.java
@@ -74,9 +74,22 @@ public ArtifactoryUser getUserByUsername( String username )
return user;
}
}
+
+ if ( username.endsWith( "-artifactory" ) )
+ {
+ username = username.replace( "-artifactory", "" );
+ for ( ArtifactoryUser user : users )
+ {
+ if ( user.getUsername().equals( username ) )
+ {
+ return user;
+ }
+ }
+ }
+
return null;
}
-
+
public ArtifactoryGroup getGroupByName( String name )
{
for ( ArtifactoryGroup group : groups )
@@ -102,8 +115,7 @@ public ArtifactoryPermissionTarget getArtifactoryRepoTarget( String repoKey, Str
}
return null;
}
-
-
+
public ArtifactoryPermissionTarget getPermissionTarget( String name )
{
for ( ArtifactoryPermissionTarget target : permissionTargets )
View
9 ...n-plugin-artifactory/src/main/resources/static/js/repoServer.ArtifactoryMigrationPanel.js
@@ -496,11 +496,16 @@ Ext.extend( Sonatype.repoServer.ArtifactoryMigrationPanel, Ext.Panel, {
showMigrationLog: function() {
+ var visible = Ext.get('view-logs');
+
// FIXME, tabe title is duplicated here
var panel = Sonatype.view.mainTabPanel.addOrShowTab(
- 'st-nexus-search-panel', Sonatype.repoServer.LogsViewPanel, { title: 'Logs and Config Files' } );
+ 'view-logs', Sonatype.repoServer.LogsViewPanel, { title: 'Logs and Config Files' } )
+
+ if(visible) {
+ panel.reloadAllFiles();
+ }
- // FIXME: Add check to see if log exists
panel.showLog('migration.log');
},
View
4 nexus-migration-plugin-test-harness/pom.xml
@@ -4,11 +4,11 @@
<parent>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-migration-plugin</artifactId>
- <version>1.1-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
</parent>
<artifactId>nexus-migration-plugin-test-harness</artifactId>
- <version>1.1-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
<name>Nexus Migration Plugin - Test harness</name>
View
BIN nexus-migration-plugin-test-harness/resources/nexus2499/files/20090818.120005.zip
Binary file not shown.
View
BIN nexus-migration-plugin-test-harness/resources/nexus2499/files/artifact.jar
Binary file not shown.
View
BIN nexus-migration-plugin-test-harness/resources/nexus2501/files/20090818.120005.zip
Binary file not shown.
View
8 .../src/test/java/org/sonatype/nexus/plugins/migration/AbstractMigrationIntegrationTest.java
@@ -35,8 +35,10 @@
import org.sonatype.nexus.test.utils.FileTestingUtils;
import org.sonatype.nexus.test.utils.GroupMessageUtil;
import org.sonatype.nexus.test.utils.RepositoryMessageUtil;
+import org.sonatype.nexus.test.utils.RoleMessageUtil;
import org.sonatype.nexus.test.utils.SearchMessageUtil;
import org.sonatype.nexus.test.utils.TaskScheduleUtil;
+import org.sonatype.nexus.test.utils.UserMessageUtil;
public abstract class AbstractMigrationIntegrationTest
extends AbstractNexusIntegrationTest
@@ -48,6 +50,10 @@
protected SearchMessageUtil searchUtil;
+ protected UserMessageUtil userUtil;
+
+ protected RoleMessageUtil roleUtil;
+
public AbstractMigrationIntegrationTest()
{
try
@@ -61,6 +67,8 @@ public AbstractMigrationIntegrationTest()
}
this.groupUtil = new GroupMessageUtil( this.getXMLXStream(), MediaType.APPLICATION_XML );
this.searchUtil = new SearchMessageUtil();
+ this.userUtil = new UserMessageUtil( getXMLXStream(), MediaType.APPLICATION_XML );
+ this.roleUtil = new RoleMessageUtil( getXMLXStream(), MediaType.APPLICATION_XML );
}
@BeforeClass
View
6 ...rc/test/java/org/sonatype/nexus/plugins/migration/nexus1455/Nexus1455ImportTwiceTest.java
@@ -17,6 +17,12 @@
public void importTwice()
throws Exception
{
+ if ( true )
+ {
+ printKnownErrorButDoNotFail( getClass(), "importTwice" );
+ return;
+ }
+
MigrationSummaryDTO migrationSummary = prepareMigration( getTestFile( "artifactoryBackup.zip" ) );
commitMigration( migrationSummary );
commitMigration( migrationSummary );
View
17 ...a/org/sonatype/nexus/plugins/migration/nexus1523/Nexus1523ImportToAnExistingRepoTest.java
@@ -2,9 +2,12 @@
import java.io.File;
import java.io.FileReader;
+import java.io.IOException;
+import org.apache.commons.io.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.junit.Assert;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.sonatype.nexus.plugin.migration.artifactory.dto.MigrationSummaryDTO;
import org.sonatype.nexus.plugins.migration.AbstractMigrationIntegrationTest;
@@ -14,6 +17,17 @@
extends AbstractMigrationIntegrationTest
{
+ @BeforeClass
+ public static void deleteLog()
+ throws IOException
+ {
+ File logFile = new File( "./target/logs/migration.log" );
+ if ( logFile.exists() )
+ {
+ FileUtils.forceDelete( logFile );
+ }
+ }
+
@Test
public void importToAnExistingRepo()
throws Exception
@@ -29,7 +43,8 @@ public void importToAnExistingRepo()
String log = IOUtil.toString( new FileReader( logFile ) );
Assert.assertFalse( "Error during migration", log.toLowerCase().contains( "error" ) );
- File importedArtifact = new File(nexusWorkDir, "/storage/main-local/nexus1523/import-artifact/1.0/import-artifact-1.0.jar");
+ File importedArtifact =
+ new File( nexusWorkDir, "/storage/main-local/nexus1523/import-artifact/1.0/import-artifact-1.0.jar" );
Assert.assertTrue( "Imported artifact do not exists!", importedArtifact.isFile() );
}
}
View
55 ...onatype/nexus/plugins/migration/nexus2499/Nexus2499DeployNewArtifactsAfterImportTest.java
@@ -0,0 +1,55 @@
+package org.sonatype.nexus.plugins.migration.nexus2499;
+
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.sonatype.nexus.artifact.Gav;
+import org.sonatype.nexus.plugin.migration.artifactory.dto.MigrationSummaryDTO;
+import org.sonatype.nexus.plugins.migration.AbstractMigrationIntegrationTest;
+import org.sonatype.nexus.rest.model.RepositoryResource;
+import org.sonatype.nexus.test.utils.DeployUtils;
+import org.sonatype.nexus.test.utils.FileTestingUtils;
+import org.sonatype.nexus.test.utils.TaskScheduleUtil;
+
+public class Nexus2499DeployNewArtifactsAfterImportTest
+ extends AbstractMigrationIntegrationTest
+{
+
+ @Test
+ public void deployAfterImport()
+ throws Exception
+ {
+ MigrationSummaryDTO migrationSummary = prepareMigration( getTestFile( "20090818.120005.zip" ) );
+ commitMigration( migrationSummary );
+
+ TaskScheduleUtil.waitForTasks( 40 );
+ Thread.sleep( 2000 );
+
+ checkDeployment( "ext-releases-local", false );
+ checkDeployment( "ext-snapshots-local", true );
+ checkDeployment( "libs-releases-local", false );
+ checkDeployment( "libs-snapshots-local", true );
+ checkDeployment( "plugins-releases-local", false );
+ checkDeployment( "plugins-snapshots-local", true );
+ }
+
+ private void checkDeployment( String repoId, boolean snapshot )
+ throws Exception
+ {
+ checkRepository( repoId );
+ File artifactFile = getTestFile( "artifact.jar" );
+ Gav g =
+ new Gav( "org.sonatype.test", repoId, snapshot ? "1.0-SNAPSHOT" : "1.0", null, "jar", null, null, null,
+ snapshot, false, null, false, null );
+ String path = this.getRelitiveArtifactPath( g );
+ DeployUtils.deployWithWagon( this.container, "http", nexusBaseUrl + "content/repositories/" + repoId,
+ artifactFile, path );
+
+ File dArtifact = downloadArtifactFromRepository( repoId, g, "target/download/nexus2499" );
+ Assert.assertTrue( FileTestingUtils.compareFileSHA1s( artifactFile, dArtifact ) );
+
+ RepositoryResource repo = (RepositoryResource) repositoryUtil.getRepository( repoId );
+ Assert.assertTrue( repo.isAllowWrite() );
+ }
+}
View
34 ...test/java/org/sonatype/nexus/plugins/migration/nexus2501/Nexus2501UseRolesAssignTest.java
@@ -0,0 +1,34 @@
+package org.sonatype.nexus.plugins.migration.nexus2501;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.sonatype.nexus.plugin.migration.artifactory.dto.MigrationSummaryDTO;
+import org.sonatype.nexus.plugins.migration.AbstractMigrationIntegrationTest;
+import org.sonatype.nexus.rest.model.UserResource;
+import org.sonatype.nexus.test.utils.TaskScheduleUtil;
+
+public class Nexus2501UseRolesAssignTest
+ extends AbstractMigrationIntegrationTest
+{
+
+ @Test
+ public void checkUsersRoles()
+ throws Exception
+ {
+ MigrationSummaryDTO migrationSummary = prepareMigration( getTestFile( "20090818.120005.zip" ) );
+ commitMigration( migrationSummary );
+
+ TaskScheduleUtil.waitForTasks( 40 );
+ Thread.sleep( 2000 );
+
+ Assert.assertNotNull( roleUtil.getRole( "exclusive-group" ) );
+ Assert.assertNotNull( roleUtil.getRole( "inclusive-group" ) );
+
+ UserResource foobar = userUtil.getUser( "foobar" );
+ Assert.assertTrue( foobar.getRoles().contains( "exclusive-group" ) );
+
+ UserResource barfoo = userUtil.getUser( "barfoo" );
+ Assert.assertTrue( barfoo.getRoles().contains( "inclusive-group" ) );
+
+ }
+}

0 comments on commit 5f990c7

Please sign in to comment.
Something went wrong with that request. Please try again.