This repository has been archived by the owner on Feb 23, 2018. It is now read-only.
forked from irods-contrib/metalnx-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/niehs-development' into issue17
- Loading branch information
Showing
537 changed files
with
70,918 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test*.properties |
90 changes: 90 additions & 0 deletions
90
packaging/src/emc-metalnx-core/attic/TestCreateTicketWithGroupRestriction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (c) 2015-2017, Dell EMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.emc.metalnx.services.tests.tickets; | ||
|
||
import com.emc.metalnx.core.domain.entity.DataGridTicket; | ||
import com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException; | ||
import com.emc.metalnx.core.domain.exceptions.DataGridException; | ||
import com.emc.metalnx.core.domain.exceptions.DataGridTicketException; | ||
import com.emc.metalnx.services.interfaces.IRODSServices; | ||
import com.emc.metalnx.services.interfaces.TicketService; | ||
import org.irods.jargon.core.exception.JargonException; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.context.web.WebAppConfiguration; | ||
|
||
import java.util.List; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* Test iRODS services. | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ContextConfiguration("classpath:test-services-context.xml") | ||
@WebAppConfiguration | ||
public class TestCreateTicketWithGroupRestriction { | ||
private static final String PUBLIC_GROUP = "public"; | ||
|
||
@Value("${irods.zoneName}") | ||
private String zone; | ||
|
||
@Value("${jobs.irods.username}") | ||
private String username; | ||
|
||
@Autowired | ||
private TicketService ticketService; | ||
|
||
@Autowired | ||
private IRODSServices irodsServices; | ||
|
||
private String targetPath, ticketString; | ||
private TestTicketUtils ticketUtils; | ||
private DataGridTicket dgt; | ||
|
||
@Before | ||
public void setUp() throws DataGridException, JargonException { | ||
String parentPath = String.format("/%s/home", zone); | ||
targetPath = String.format("%s/%s", parentPath, username); | ||
ticketUtils = new TestTicketUtils(irodsServices); | ||
|
||
dgt = new DataGridTicket(targetPath); | ||
dgt.addGroup(PUBLIC_GROUP); | ||
} | ||
|
||
@After | ||
public void tearDown() throws JargonException { | ||
ticketUtils.deleteTicket(ticketString); | ||
} | ||
|
||
@Test | ||
public void testCreateTicketWithHostRestriction() throws DataGridConnectionRefusedException, | ||
DataGridTicketException, JargonException { | ||
ticketString = ticketService.create(dgt); | ||
List<String> groups = ticketUtils.listAllGroupRestrictionsForSpecifiedTicket(ticketString); | ||
|
||
assertEquals(1, groups.size()); | ||
assertTrue(groups.contains(PUBLIC_GROUP)); | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
packaging/src/emc-metalnx-core/attic/TestDownloadWithTicket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
* Copyright (c) 2015-2017, Dell EMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.emc.metalnx.services.tests.tickets; | ||
|
||
import com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException; | ||
import com.emc.metalnx.core.domain.exceptions.DataGridException; | ||
import com.emc.metalnx.core.domain.exceptions.DataGridTicketDownloadException; | ||
import com.emc.metalnx.core.domain.exceptions.DataGridTicketInvalidUserException; | ||
import com.emc.metalnx.services.interfaces.IRODSServices; | ||
import com.emc.metalnx.services.interfaces.TicketClientService; | ||
import org.apache.commons.io.FileUtils; | ||
import org.irods.jargon.core.exception.JargonException; | ||
import org.irods.jargon.core.pub.Stream2StreamAO; | ||
import org.irods.jargon.core.pub.io.IRODSFile; | ||
import org.irods.jargon.ticket.packinstr.TicketCreateModeEnum; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.context.web.WebAppConfiguration; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
import static junit.framework.Assert.assertNotNull; | ||
|
||
/** | ||
* Test iRODS services. | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ContextConfiguration("classpath:test-services-context.xml") | ||
@WebAppConfiguration | ||
public class TestDownloadWithTicket { | ||
private static final String FILE_CONTENT = "Test for ticket"; | ||
private static final int BUFFER_SIZE = 4 * 1024 * 1024; | ||
|
||
@Value("${irods.zoneName}") | ||
private String zone; | ||
|
||
@Value("${jobs.irods.username}") | ||
private String username; | ||
|
||
@Autowired | ||
private IRODSServices irodsServices; | ||
|
||
@Autowired | ||
private TicketClientService ticketClientService; | ||
|
||
private String targetPath, filePath, ticketString; | ||
private TestTicketUtils ticketUtils; | ||
private File localFile, fileFromIRods; | ||
|
||
@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); | ||
localFile = ticketUtils.createLocalFile(); | ||
ticketString = ticketUtils.createTicket(parentPath, username, TicketCreateModeEnum.READ); | ||
uploadFileToIRODS(targetPath, localFile); | ||
filePath = String.format("%s/%s", targetPath, localFile.getName()); | ||
} | ||
|
||
@After | ||
public void tearDown() throws JargonException, DataGridConnectionRefusedException { | ||
FileUtils.deleteQuietly(localFile); | ||
FileUtils.deleteQuietly(fileFromIRods); | ||
ticketUtils.deleteTicket(ticketString); | ||
ticketUtils.deleteIRODSFile(filePath); | ||
} | ||
|
||
@Test | ||
public void testDownloadFileUsingATicket() throws DataGridTicketDownloadException, DataGridTicketInvalidUserException, | ||
IOException { | ||
fileFromIRods = ticketClientService.getFileFromIRODSUsingTicket(ticketString, filePath); | ||
assertNotNull(fileFromIRods); | ||
assertEquals(TestTicketUtils.TICKET_FILE_CONTENT, FileUtils.readFileToString(fileFromIRods, StandardCharsets.UTF_8.name())); | ||
} | ||
|
||
private void uploadFileToIRODS(String path, File file) throws DataGridConnectionRefusedException, JargonException, | ||
IOException { | ||
IRODSFile targetFile = irodsServices.getIRODSFileFactory().instanceIRODSFile(path, file.getName()); | ||
|
||
if (targetFile.exists()) { | ||
return; | ||
} | ||
|
||
Stream2StreamAO streamAO = irodsServices.getStream2StreamAO(); | ||
InputStream inputStream = new FileInputStream(file); | ||
streamAO.transferStreamToFileUsingIOStreams(inputStream, (File) targetFile, 0, BUFFER_SIZE); | ||
inputStream.close(); | ||
targetFile.close(); | ||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
packaging/src/emc-metalnx-core/attic/TestResourceService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright (c) 2015-2017, Dell EMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.emc.metalnx.services.tests.resource; | ||
|
||
import com.emc.metalnx.core.domain.entity.DataGridResource; | ||
import com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException; | ||
import com.emc.metalnx.services.interfaces.ResourceService; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.context.web.WebAppConfiguration; | ||
|
||
import java.util.Date; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* Test Resource service. | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ContextConfiguration("classpath:test-services-context.xml") | ||
@WebAppConfiguration | ||
public class TestResourceService { | ||
|
||
public static final String RODSADMIN = "rodsadmin"; | ||
|
||
@Value("${irods.zoneName}") | ||
private String zone; | ||
|
||
@Value("${irods.host}") | ||
private String host; | ||
|
||
@Autowired | ||
private ResourceService resourceService; | ||
|
||
private String parentRescName, childRescName; | ||
|
||
private DataGridResource parentResc, childResc; | ||
|
||
@Before | ||
public void setUp() throws DataGridConnectionRefusedException { | ||
long time = System.currentTimeMillis(); | ||
parentRescName = "testResc" + time; | ||
childRescName = "testRescChild" + time; | ||
Date date = new Date(); | ||
|
||
parentResc = new DataGridResource(); | ||
parentResc.setName(parentRescName); | ||
parentResc.setType("compound"); | ||
parentResc.setZone(zone); | ||
parentResc.setCreateTime(date); | ||
parentResc.setModifyTime(date); | ||
parentResc.setFreeSpaceDate(date); | ||
parentResc.setPath("/var/lib/irods/iRODS/Vault2"); | ||
parentResc.setHost(host); | ||
|
||
childResc = new DataGridResource(); | ||
childResc.setName(childRescName); | ||
childResc.setType("unixfilesystem"); | ||
childResc.setZone(zone); | ||
childResc.setCreateTime(date); | ||
childResc.setModifyTime(date); | ||
childResc.setFreeSpaceDate(date); | ||
childResc.setPath("/var/lib/irods/iRODS/Vault2"); | ||
childResc.setHost(host); | ||
|
||
resourceService.createResource(parentResc); | ||
} | ||
|
||
@After | ||
public void tearDown() throws DataGridConnectionRefusedException { | ||
if (resourceService.find(parentRescName) != null) | ||
resourceService.deleteResource(parentRescName); | ||
|
||
if (resourceService.find(childRescName) != null) | ||
resourceService.deleteResource(childRescName); | ||
} | ||
|
||
@Test | ||
public void testDeleteResourceByName() { | ||
assertTrue(resourceService.deleteResource(parentRescName)); | ||
} | ||
|
||
@Test | ||
public void testDeleteResourceWithChildren() throws DataGridConnectionRefusedException { | ||
resourceService.createResource(childResc); | ||
resourceService.addChildToResource(parentRescName, childRescName); | ||
|
||
assertTrue(resourceService.deleteResource(parentRescName)); | ||
assertNotNull(resourceService.find(childRescName)); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.