Skip to content
This repository has been archived by the owner on Feb 23, 2018. It is now read-only.

Commit

Permalink
Merge branch 'issue52' into 'niehs-master'
Browse files Browse the repository at this point in the history
Issue52

See merge request conwaymc/metalnx-web!7
  • Loading branch information
michael-conway committed Nov 28, 2017
2 parents be893a3 + ea8ea38 commit ac5677a
Show file tree
Hide file tree
Showing 518 changed files with 70,659 additions and 104 deletions.
1 change: 1 addition & 0 deletions DEVELOPER-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ In addition, an additional profile for Metalnx is required, like this...
<selenium.test.hostname>localhost</selenium.test.hostname>
<selenium.test.chrome.driver>webdriver.chrome.driver</selenium.test.chrome.driver>
<selenium.test.chrome.driver.loaction>C:/Users/pateldes/driver/chromedriver.exe</selenium.test.chrome.driver.loaction>
<metalnx.enable.tickets>true</metalnx.enable.tickets>
</properties>
</profile>

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![Metalnx Logo](docs/IMAGES/mlx_logo_blue.png)

## Version: 4.2.1.0-SNAPSHOT
## Git Tag: niehs/issue2
## Git Tag: niehs/issue52
## Date: Oct 27, 2017


Expand Down Expand Up @@ -87,6 +87,10 @@ The current Selenium tests have been refactored to start with basic health check

Updated Jargon and controller code to gracefully handle no permission errors with a helpful message and a return to the previous directory view

#### NIEHS identified misc theming issues
#### Add properties based global control of features targeted at first towards removing tickets niehs #52

Add a global config to turn on/off certain features via metalnx.properties. This allows sites to globally turn off features such as tickets.

#### NIEHS identified misc theming issues

* #22 fix search text
5 changes: 5 additions & 0 deletions etc/irods-ext/metalnx.properties
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ msi.irods.list=libmsisync_to_archive.so,libmsi_update_unixfilesystem_resource_fr
msi.irods.42.list=libmsisync_to_archive.so,libmsi_update_unixfilesystem_resource_free_space.so

msi.other.list=

######################################
# global feature flags
# controls access to features globally
metalnx.enable.tickets=false
1 change: 1 addition & 0 deletions packaging/src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test*.properties
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 packaging/src/emc-metalnx-core/attic/TestDownloadWithTicket.java
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 packaging/src/emc-metalnx-core/attic/TestResourceService.java
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));
}


}
Loading

0 comments on commit ac5677a

Please sign in to comment.