]> source.dussan.org Git - archiva.git/commitdiff
test passing no url still work
authorOlivier Lamy <olamy@apache.org>
Fri, 25 May 2012 12:32:40 +0000 (12:32 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 25 May 2012 12:32:40 +0000 (12:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1342594 13f79535-47bb-0310-9956-ffa450edef68

redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/UserServiceTest.java

index c31f67ffa8e44b0b5dabeb9c81d3a11991b5d29a..41c8fcdee9dba3846fc53a9ef8c3ae6c3e910c0a 100644 (file)
@@ -179,6 +179,65 @@ public class UserServiceTest
 
     }
 
+    @Test
+    public void registerNoUrl()
+        throws Exception
+    {
+        try
+        {
+            UserService service = getUserService();
+            User u = new User();
+            u.setFullName( "the toto" );
+            u.setUsername( "toto" );
+            u.setEmail( "toto@toto.fr" );
+            u.setPassword( "toto123" );
+            u.setConfirmPassword( "toto123" );
+            String key = service.registerUser( new UserRegistrationRequest( u, null ) ).getKey();
+
+            assertFalse( key.equals( "-1" ) );
+
+            ServicesAssert assertService =
+                JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/testsService/",
+                                           ServicesAssert.class,
+                                           Collections.singletonList( new JacksonJaxbJsonProvider() ) );
+
+            List<EmailMessage> emailMessages = assertService.getEmailMessageSended();
+            assertEquals( 1, emailMessages.size() );
+            assertEquals( "toto@toto.fr", emailMessages.get( 0 ).getTos().get( 0 ) );
+
+            assertEquals( "Welcome", emailMessages.get( 0 ).getSubject() );
+            String messageContent = emailMessages.get( 0 ).getText();
+
+            log.info( "messageContent: {}", messageContent );
+
+            assertThat( messageContent ).contains( "Use the following URL to validate your account." ).contains(
+                "http://localhost:" + port ).containsIgnoringCase( "toto" );
+
+            assertTrue( service.validateUserFromKey( key ) );
+
+            service = getUserService( authorizationHeader );
+
+            u = service.getUser( "toto" );
+
+            assertNotNull( u );
+            assertTrue( u.isValidated() );
+            assertTrue( u.isPasswordChangeRequired() );
+
+            assertTrue( service.validateUserFromKey( key ) );
+
+        }
+        catch ( Exception e )
+        {
+            log.error( e.getMessage(), e );
+            throw e;
+        }
+        finally
+        {
+            getUserService( authorizationHeader ).deleteUser( "toto" );
+        }
+
+    }
+
     @Test
     public void resetPassword()
         throws Exception