Search in sources :

Example 16 with SetAttr3

use of org.apache.hadoop.nfs.nfs3.request.SetAttr3 in project hadoop by apache.

the class TestRpcProgramNfs3 method testSymlink.

@Test(timeout = 60000)
public void testSymlink() throws Exception {
    HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
    long dirId = status.getFileId();
    XDR xdr_req = new XDR();
    FileHandle handle = new FileHandle(dirId);
    SYMLINK3Request req = new SYMLINK3Request(handle, "fubar", new SetAttr3(), "bar");
    req.serialize(xdr_req);
    // Attempt by an unprivileged user should fail.
    SYMLINK3Response response1 = nfsd.symlink(xdr_req.asReadOnlyWrap(), securityHandlerUnpriviledged, new InetSocketAddress("localhost", 1234));
    assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES, response1.getStatus());
    // Attempt by a privileged user should pass.
    SYMLINK3Response response2 = nfsd.symlink(xdr_req.asReadOnlyWrap(), securityHandler, new InetSocketAddress("localhost", 1234));
    assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK, response2.getStatus());
}
Also used : SYMLINK3Request(org.apache.hadoop.nfs.nfs3.request.SYMLINK3Request) SetAttr3(org.apache.hadoop.nfs.nfs3.request.SetAttr3) FileHandle(org.apache.hadoop.nfs.nfs3.FileHandle) InetSocketAddress(java.net.InetSocketAddress) HdfsFileStatus(org.apache.hadoop.hdfs.protocol.HdfsFileStatus) XDR(org.apache.hadoop.oncrpc.XDR) SYMLINK3Response(org.apache.hadoop.nfs.nfs3.response.SYMLINK3Response) Test(org.junit.Test)

Example 17 with SetAttr3

use of org.apache.hadoop.nfs.nfs3.request.SetAttr3 in project hadoop by apache.

the class TestRpcProgramNfs3 method testSetattr.

@Test(timeout = 60000)
public void testSetattr() throws Exception {
    HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
    long dirId = status.getFileId();
    XDR xdr_req = new XDR();
    FileHandle handle = new FileHandle(dirId);
    SetAttr3 symAttr = new SetAttr3(0, 1, 0, 0, null, null, EnumSet.of(SetAttrField.UID));
    SETATTR3Request req = new SETATTR3Request(handle, symAttr, false, null);
    req.serialize(xdr_req);
    // Attempt by an unprivileged user should fail.
    SETATTR3Response response1 = nfsd.setattr(xdr_req.asReadOnlyWrap(), securityHandlerUnpriviledged, new InetSocketAddress("localhost", 1234));
    assertEquals("Incorrect return code", Nfs3Status.NFS3ERR_ACCES, response1.getStatus());
    // Attempt by a priviledged user should pass.
    SETATTR3Response response2 = nfsd.setattr(xdr_req.asReadOnlyWrap(), securityHandler, new InetSocketAddress("localhost", 1234));
    assertEquals("Incorrect return code", Nfs3Status.NFS3_OK, response2.getStatus());
}
Also used : SetAttr3(org.apache.hadoop.nfs.nfs3.request.SetAttr3) FileHandle(org.apache.hadoop.nfs.nfs3.FileHandle) InetSocketAddress(java.net.InetSocketAddress) HdfsFileStatus(org.apache.hadoop.hdfs.protocol.HdfsFileStatus) XDR(org.apache.hadoop.oncrpc.XDR) SETATTR3Request(org.apache.hadoop.nfs.nfs3.request.SETATTR3Request) SETATTR3Response(org.apache.hadoop.nfs.nfs3.response.SETATTR3Response) Test(org.junit.Test)

Aggregations

FileHandle (org.apache.hadoop.nfs.nfs3.FileHandle)16 SetAttr3 (org.apache.hadoop.nfs.nfs3.request.SetAttr3)11 XDR (org.apache.hadoop.oncrpc.XDR)9 InetSocketAddress (java.net.InetSocketAddress)8 HdfsFileStatus (org.apache.hadoop.hdfs.protocol.HdfsFileStatus)8 Test (org.junit.Test)8 CREATE3Request (org.apache.hadoop.nfs.nfs3.request.CREATE3Request)6 DFSClient (org.apache.hadoop.hdfs.DFSClient)5 CREATE3Response (org.apache.hadoop.nfs.nfs3.response.CREATE3Response)5 IOException (java.io.IOException)3 FsPermission (org.apache.hadoop.fs.permission.FsPermission)3 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)3 NfsConfiguration (org.apache.hadoop.hdfs.nfs.conf.NfsConfiguration)3 READ3Request (org.apache.hadoop.nfs.nfs3.request.READ3Request)3 WRITE3Request (org.apache.hadoop.nfs.nfs3.request.WRITE3Request)3 READ3Response (org.apache.hadoop.nfs.nfs3.response.READ3Response)3 SecurityHandler (org.apache.hadoop.oncrpc.security.SecurityHandler)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Nfs3FileAttributes (org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes)2 MKDIR3Request (org.apache.hadoop.nfs.nfs3.request.MKDIR3Request)2