use of edu.uiuc.ncsa.security.core.exceptions.FilePermissionsException in project OA4MP by ncsa.
the class FSCAStoreTest method testPermissions.
public void testPermissions() throws Exception {
File storeDirectory = File.createTempFile("fs-store", "-tmp");
File indexDirectory = File.createTempFile("fs-index", "-tmp");
storeDirectory.setWritable(false);
indexDirectory.setWritable(false);
assert !storeDirectory.canWrite();
FSClientApprovalStore x = null;
final ClientApprovalProvider caProvider = new ClientApprovalProvider();
try {
// Make sure that if someone creates a bad one, it blows up in the constructor.
x = new FSClientApprovalStore(null, null, null, null) {
@Override
public Object put(Object key, Object value) {
return null;
}
};
assert false : "Could make a new object without being properly configured";
} catch (MyConfigurationException xx) {
assert true;
}
x = new DSFSClientApprovalStore(storeDirectory, indexDirectory, caProvider, new ClientApproverConverter(caProvider));
try {
// should bomb here.
x.create();
assert false;
} catch (FilePermissionsException xx) {
assert true;
}
// so make a new entry and then have retrieving it fail.
storeDirectory.setWritable(true);
indexDirectory.setWritable(true);
ClientApproval ca = (ClientApproval) x.create();
// fail for store directory un readable
storeDirectory.setReadable(false);
try {
x.get(ca.getIdentifier());
assert false;
} catch (FilePermissionsException xx) {
assert true;
}
}
use of edu.uiuc.ncsa.security.core.exceptions.FilePermissionsException in project OA4MP by ncsa.
the class NewCAStoreTest method testPermissions.
public void testPermissions() throws Exception {
File storeDirectory = File.createTempFile("fs-store", "-tmp");
File indexDirectory = File.createTempFile("fs-index", "-tmp");
storeDirectory.setWritable(false);
indexDirectory.setWritable(false);
assert !storeDirectory.canWrite();
FSClientApprovalStore x = null;
final ClientApprovalProvider caProvider = new ClientApprovalProvider();
try {
// Make sure that if someone creates a bad one, it blows up in the constructor.
x = new FSClientApprovalStore(null, null, null, null) {
@Override
public Object put(Object key, Object value) {
return null;
}
};
assert false : "Could make a new object without being properly configured";
} catch (MyConfigurationException xx) {
assert true;
}
x = new DSFSClientApprovalStore(storeDirectory, indexDirectory, caProvider, new ClientApproverConverter(caProvider));
try {
// should bomb here.
x.create();
assert false;
} catch (FilePermissionsException xx) {
assert true;
}
// so make a new entry and then have retrieving it fail.
storeDirectory.setWritable(true);
indexDirectory.setWritable(true);
ClientApproval ca = (ClientApproval) x.create();
// fail for store directory un readable
storeDirectory.setReadable(false);
try {
x.get(ca.getIdentifier());
assert false;
} catch (FilePermissionsException xx) {
assert true;
}
}
Aggregations