Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
File Repository
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Operations
Operations
Incidents
Environments
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
File Repository
Commits
a6317a0d
Commit
a6317a0d
authored
Sep 29, 2018
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated FTP server tests for ACL support in repository
parent
1b554517
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
13 deletions
+41
-13
file-repository-ftpserver/pom.xml
file-repository-ftpserver/pom.xml
+14
-0
file-repository-ftpserver/src/test/java/org/genesys/filerepository/service/ftp/ApplicationConfig.java
...genesys/filerepository/service/ftp/ApplicationConfig.java
+26
-8
file-repository-ftpserver/src/test/java/org/genesys/filerepository/service/ftp/FtpServerTest.java
...org/genesys/filerepository/service/ftp/FtpServerTest.java
+1
-5
No files found.
file-repository-ftpserver/pom.xml
View file @
a6317a0d
...
...
@@ -57,6 +57,13 @@
<version>
${spring.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<artifactId>
spring-security-test
</artifactId>
<version>
${spring.security.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
commons-net
</groupId>
...
...
@@ -80,6 +87,13 @@
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
javax.inject
</groupId>
<artifactId>
javax.inject
</artifactId>
<version>
1
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
...
...
file-repository-ftpserver/src/test/java/org/genesys/filerepository/service/ftp/ApplicationConfig.java
View file @
a6317a0d
...
...
@@ -16,6 +16,7 @@
package
org.genesys.filerepository.service.ftp
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
org.apache.ftpserver.ftplet.Authentication
;
...
...
@@ -29,8 +30,11 @@ import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication;
import
org.apache.ftpserver.usermanager.impl.AbstractUserManager
;
import
org.apache.ftpserver.usermanager.impl.ConcurrentLoginPermission
;
import
org.apache.ftpserver.usermanager.impl.WritePermission
;
import
org.genesys.blocks.security.model.BasicUser
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
/**
* The Class ApplicationConfig.
...
...
@@ -128,10 +132,10 @@ public class ApplicationConfig {
if
(
authentication
instanceof
UsernamePasswordAuthentication
)
{
final
UsernamePasswordAuthentication
upauth
=
(
UsernamePasswordAuthentication
)
authentication
;
final
String
user
=
upauth
.
getUsername
();
final
String
user
name
=
upauth
.
getUsername
();
String
password
=
upauth
.
getPassword
();
if
(
user
==
null
)
{
if
(
user
name
==
null
)
{
throw
new
AuthenticationFailedException
(
"Authentication failed"
);
}
...
...
@@ -139,7 +143,7 @@ public class ApplicationConfig {
password
=
""
;
}
final
String
storedPassword
=
user
.
concat
(
"1!"
);
final
String
storedPassword
=
user
name
.
concat
(
"1!"
);
if
(!
password
.
equals
(
storedPassword
))
{
// user does not exist
...
...
@@ -148,11 +152,25 @@ public class ApplicationConfig {
// if (getPasswordEncryptor().matches(password, storedPassword)) {
if
(
password
.
equals
(
storedPassword
))
{
try
{
return
getUserByName
(
user
);
}
catch
(
final
FtpException
e
)
{
throw
new
AuthenticationFailedException
(
"Authentication failed"
,
e
);
}
// using this to grant us ADMIN role
BasicUser
<
GrantedAuthority
>
user
=
new
BasicUser
<
GrantedAuthority
>()
{
@Override
public
Collection
<?
extends
GrantedAuthority
>
getAuthorities
()
{
List
<
GrantedAuthority
>
roles
=
new
ArrayList
<>();
roles
.
add
(
new
SimpleGrantedAuthority
(
"ROLE_ADMINISTRATOR"
));
return
roles
;
}
};
FtpUser
ftpUser
=
new
FtpUser
(
user
);
ftpUser
.
setName
(
username
);
final
List
<
Authority
>
authorities
=
new
ArrayList
<>();
authorities
.
add
(
new
ConcurrentLoginPermission
(
10
,
0
));
authorities
.
add
(
new
WritePermission
());
ftpUser
.
setAuthorities
(
authorities
);
ftpUser
.
setHomeDirectory
(
"/"
);
return
ftpUser
;
}
else
{
throw
new
AuthenticationFailedException
(
"Authentication failed"
);
}
...
...
file-repository-ftpserver/src/test/java/org/genesys/filerepository/service/ftp/FtpServerTest.java
View file @
a6317a0d
...
...
@@ -15,11 +15,7 @@
*/
package
org.genesys.filerepository.service.ftp
;
import
static
org
.
hamcrest
.
Matchers
.
contains
;
import
static
org
.
hamcrest
.
Matchers
.
hasItems
;
import
static
org
.
hamcrest
.
Matchers
.
hasSize
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
notNullValue
;
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
java.io.ByteArrayInputStream
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment