diff mbox

[3/3] nfsd4: implement secinfo_no_name

Message ID 4D2E6F70.2090501@cn.fujitsu.com (mailing list archive)
State RFC, archived
Headers show

Commit Message

Mi Jinlong Jan. 13, 2011, 3:20 a.m. UTC
None
diff mbox

Patch

diff --git a/nfs4.1/server41tests/__init__.py b/nfs4.1/server41tests/__init__.py
index 22cd664..3b4411a 100644
--- a/nfs4.1/server41tests/__init__.py
+++ b/nfs4.1/server41tests/__init__.py
@@ -2,6 +2,8 @@  __all__ = ["st_exchange_id.py", # draft 21
            "st_compound.py",
            "st_create_session.py",
            "st_destroy_session.py",
+           "st_secinfo_no_name.py",
+           "st_secinfo.py",
            "st_sequence.py",
 	   "st_trunking.py",
            "st_open.py",
diff --git a/nfs4.1/server41tests/st_secinfo.py b/nfs4.1/server41tests/st_secinfo.py
new file mode 100644
index 0000000..c0e5b71
--- /dev/null
+++ b/nfs4.1/server41tests/st_secinfo.py
@@ -0,0 +1,57 @@ 
+from st_create_session import create_session
+from nfs4_const import *
+from environment import check, fail, use_obj, bad_sessionid, create_file
+from nfs4_type import channel_attrs4
+import nfs4_ops as op
+import nfs4lib
+
+def testSupported(t, env):
+    """Do a simple SECINFO
+
+    FLAGS: all
+    CODE: SEC1
+    """
+    name = env.testname(t)
+    c = env.c1.new_client(env.testname(t))
+    sess = c.create_session()
+
+    # Create a tmpfile for testing
+    owner = "owner_%s" % name
+    path = sess.c.homedir + [name]
+    res = create_file(sess, owner, path, access=OPEN4_SHARE_ACCESS_WRITE)
+    check(res)
+
+    # Get the filehandle of the tmpfile's parent dir
+    res = sess.compound(use_obj(sess.c.homedir) + [op.getfh()])
+    check(res)
+    fh = res.resarray[-1].object
+
+    # Just do a simple SECINFO
+    res = sess.compound([op.putfh(fh), op.secinfo(name)])
+    check(res)
+
+def testSupported2(t, env):
+    """GETFH after do a SECINFO_NO_NAME or SECINFO
+       result in a NOFILEHANDLE error, See rfc 5661 section 2.6.3.1.1.8
+
+    FLAGS: all
+    CODE: SEC2
+    """
+    name = env.testname(t)
+    c = env.c1.new_client(env.testname(t))
+    sess = c.create_session()
+
+    # Create a tmpfile for testing
+    owner = "owner_%s" % name
+    path = sess.c.homedir + [name]
+    res = create_file(sess, owner, path, access=OPEN4_SHARE_ACCESS_WRITE)
+    check(res)
+
+    # Get the filehandle of the tmpfile's parent dir
+    res = sess.compound(use_obj(sess.c.homedir) + [op.getfh()])
+    check(res)
+    fh = res.resarray[-1].object
+
+    # GETFH after do a SECINFO should get error NFS4ERR_NOFILEHANDLE
+    res = sess.compound([op.putfh(fh), op.secinfo(name), op.getfh()])
+    check(res, NFS4ERR_NOFILEHANDLE)
diff --git a/nfs4.1/server41tests/st_secinfo_no_name.py b/nfs4.1/server41tests/st_secinfo_no_name.py
new file mode 100644
index 0000000..14bc410
--- /dev/null
+++ b/nfs4.1/server41tests/st_secinfo_no_name.py
@@ -0,0 +1,35 @@ 
+from st_create_session import create_session
+from nfs4_const import *
+from environment import check, fail, bad_sessionid, create_file
+from nfs4_type import channel_attrs4
+import nfs4_ops as op
+import nfs4lib
+
+def testSupported(t, env):
+    """Do a simple SECINFO_NO_NAME
+       send PUTROOTFH+SECINFO_NO_NAME, check is result legal
+
+    FLAGS: all
+    CODE: SECNN1
+    """
+    c = env.c1.new_client(env.testname(t))
+    sess = c.create_session()
+
+    # Do a simple SECINFO_NO_NAME
+    res = sess.compound([op.putrootfh(), op.secinfo_no_name(0)])
+    check(res)
+
+def testSupported2(t, env):
+    """GETFH after do a SECINFO_NO_NAME or SECINFO
+       result in a NOFILEHANDLE error, See rfc 5661 section 2.6.3.1.1.8
+
+    FLAGS: all
+    CODE: SECNN2
+    """
+    c = env.c1.new_client(env.testname(t))
+    sess = c.create_session()
+
+    # GETFH after do a SECINFO_NO_NAME should get error NFS4ERR_NOFILEHANDLE
+    res = sess.compound([op.putrootfh(), op.secinfo_no_name(0), op.getfh()])
+    print res
+    check(res, NFS4ERR_NOFILEHANDLE)