Search in sources :

Example 1 with TestTicketUtils

use of com.emc.metalnx.services.tests.tickets.TestTicketUtils in project metalnx-web by irods-contrib.

the class TestTicketAuthenticatedAccess method setUp.

@Before
public void setUp() throws DataGridException, JargonException, IOException {
    String parentPath = String.format("/%s/home", zone);
    targetPath = String.format("%s/%s", parentPath, username);
    ticketUtils = new TestTicketUtils(irodsServices);
    ticketString = ticketUtils.createTicket(parentPath, username, TicketCreateModeEnum.WRITE);
    localFile = ticketUtils.createLocalFile();
    filePath = String.format("%s/%s", targetPath, localFile.getName());
    IRODSAccount authIrodsAccount = IRODSAccount.instance(host, Integer.valueOf(port), username, password, targetPath, zone, RESOURCE);
    UserTokenDetails userTokenDetails = Mockito.mock(UserTokenDetails.class);
    Authentication authentication = Mockito.mock(Authentication.class);
    SecurityContext securityContext = Mockito.mock(SecurityContext.class);
    SecurityContextHolder.setContext(securityContext);
    Mockito.when(securityContext.getAuthentication()).thenReturn(authentication);
    Mockito.when(authentication.getDetails()).thenReturn(userTokenDetails);
    Mockito.when(userTokenDetails.getIrodsAccount()).thenReturn(authIrodsAccount);
}
Also used : UserTokenDetails(com.emc.metalnx.services.auth.UserTokenDetails) IRODSAccount(org.irods.jargon.core.connection.IRODSAccount) Authentication(org.springframework.security.core.Authentication) TestTicketUtils(com.emc.metalnx.services.tests.tickets.TestTicketUtils) SecurityContext(org.springframework.security.core.context.SecurityContext) Before(org.junit.Before)

Example 2 with TestTicketUtils

use of com.emc.metalnx.services.tests.tickets.TestTicketUtils in project metalnx-web by irods-contrib.

the class TestTicketWithUserRestriction method setUp.

@Before
public void setUp() throws DataGridException, JargonException, IOException {
    String parentPath = String.format("/%s/home", zone);
    targetPath = String.format("%s/%s", parentPath, username);
    ticketUtils = new TestTicketUtils(irodsServices);
    ticketString = ticketUtils.createTicket(parentPath, username, TicketCreateModeEnum.WRITE);
    ticketUtils.addUserRestriction(ticketString, username);
    localFile = ticketUtils.createLocalFile();
    filePath = String.format("%s/%s", targetPath, localFile.getName());
}
Also used : TestTicketUtils(com.emc.metalnx.services.tests.tickets.TestTicketUtils) Before(org.junit.Before)

Example 3 with TestTicketUtils

use of com.emc.metalnx.services.tests.tickets.TestTicketUtils in project metalnx-web by irods-contrib.

the class TestTicketWithHostRestriction method setUp.

@Before
public void setUp() throws DataGridException, JargonException, IOException {
    String parentPath = String.format("/%s/home", zone);
    targetPath = String.format("%s/%s", parentPath, username);
    ticketUtils = new TestTicketUtils(irodsServices);
    ticketString = ticketUtils.createTicket(parentPath, username, TicketCreateModeEnum.WRITE);
    ticketUtils.addHostRestriction(ticketString, host);
    localFile = ticketUtils.createLocalFile();
    filePath = String.format("%s/%s", targetPath, localFile.getName());
}
Also used : TestTicketUtils(com.emc.metalnx.services.tests.tickets.TestTicketUtils) Before(org.junit.Before)

Example 4 with TestTicketUtils

use of com.emc.metalnx.services.tests.tickets.TestTicketUtils in project metalnx-web by irods-contrib.

the class TestTicketWithByteLimit method setUp.

@Before
public void setUp() throws DataGridException, JargonException, IOException {
    String parentPath = String.format("/%s/home", zone);
    targetPath = String.format("%s/%s", parentPath, username);
    ticketUtils = new TestTicketUtils(irodsServices);
    ticketString = ticketUtils.createTicket(parentPath, username, TicketCreateModeEnum.WRITE);
    ticketUtils.setWriteByteLimit(ticketString, WRITE_BYTE_LIMIT);
    localFile = ticketUtils.createLocalFile();
    filePath = String.format("%s/%s", targetPath, localFile.getName());
}
Also used : TestTicketUtils(com.emc.metalnx.services.tests.tickets.TestTicketUtils) Before(org.junit.Before)

Example 5 with TestTicketUtils

use of com.emc.metalnx.services.tests.tickets.TestTicketUtils in project metalnx-web by irods-contrib.

the class TestTicketWithFilesLimit method setUp.

@Before
public void setUp() throws DataGridException, JargonException, IOException {
    String parentPath = String.format("/%s/home", zone);
    targetPath = String.format("%s/%s", parentPath, username);
    ticketUtils = new TestTicketUtils(irodsServices);
    ticketString = ticketUtils.createTicket(parentPath, username, TicketCreateModeEnum.WRITE);
    ticketUtils.setWriteFileLimit(ticketString, WRITE_FILE_LIMIT);
    localFile1 = ticketUtils.createLocalFile();
    localFile2 = ticketUtils.createLocalFile("test-ticket-2-" + System.currentTimeMillis());
    filePath1 = String.format("%s/%s", targetPath, localFile1.getName());
    filePath2 = String.format("%s/%s", targetPath, localFile2.getName());
}
Also used : TestTicketUtils(com.emc.metalnx.services.tests.tickets.TestTicketUtils) Before(org.junit.Before)

Aggregations

TestTicketUtils (com.emc.metalnx.services.tests.tickets.TestTicketUtils)8 Before (org.junit.Before)8 UserTokenDetails (com.emc.metalnx.services.auth.UserTokenDetails)1 IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)1 Authentication (org.springframework.security.core.Authentication)1 SecurityContext (org.springframework.security.core.context.SecurityContext)1