s4:torture/smb2: skip lease tests if the server doesn't support them
authorStefan Metzmacher <metze@samba.org>
Wed, 12 Nov 2014 06:19:49 +0000 (07:19 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 27 Nov 2014 15:45:05 +0000 (16:45 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/torture/smb2/lease.c

index 432695826622c363ed8f5d734dc9ae9d8ffd6999..e06faea86a5c56f73ff6a699b130c0801dff644b 100644 (file)
@@ -142,12 +142,14 @@ static bool test_lease_request(struct torture_context *tctx,
        CHECK_LEASE(&io, "RHW", true, LEASE1);
 
        /* But will reject leases on directories. */
-       smb2_lease_create(&io, &ls, true, dname, LEASE2, smb2_util_lease_state("RHW"));
-       status = smb2_create(tree, mem_ctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_DIRECTORY);
-       CHECK_LEASE(&io, "", false, 0);
-       smb2_util_close(tree, io.out.file.handle);
+       if (!(caps & SMB2_CAP_DIRECTORY_LEASING)) {
+               smb2_lease_create(&io, &ls, true, dname, LEASE2, smb2_util_lease_state("RHW"));
+               status = smb2_create(tree, mem_ctx, &io);
+               CHECK_STATUS(status, NT_STATUS_OK);
+               CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_DIRECTORY);
+               CHECK_LEASE(&io, "", false, 0);
+               smb2_util_close(tree, io.out.file.handle);
+       }
 
        /* Also rejects multiple files leased under the same key. */
        smb2_lease_create(&io, &ls, true, fname2, LEASE1, smb2_util_lease_state("RHW"));
@@ -1191,6 +1193,21 @@ static bool test_lease_v2_request_parent(struct torture_context *tctx,
        NTSTATUS status;
        const char *fname = "lease.dat";
        bool ret = true;
+       uint32_t caps;
+       enum protocol_types protocol;
+
+       caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
+       if (!(caps & SMB2_CAP_LEASING)) {
+               torture_skip(tctx, "leases are not supported");
+       }
+       if (!(caps & SMB2_CAP_DIRECTORY_LEASING)) {
+               torture_skip(tctx, "directory leases are not supported");
+       }
+
+       protocol = smbXcli_conn_protocol(tree->session->transport->conn);
+       if (protocol < PROTOCOL_SMB3_00) {
+               torture_skip(tctx, "v2 leases are not supported");
+       }
 
        smb2_util_unlink(tree, fname);
 
@@ -1230,6 +1247,7 @@ static bool test_lease_break_twice(struct torture_context *tctx,
        const char *fname = "lease.dat";
        bool ret = true;
        uint32_t caps;
+       enum protocol_types protocol;
 
        caps = smb2cli_conn_server_capabilities(
                tree->session->transport->conn);
@@ -1237,6 +1255,11 @@ static bool test_lease_break_twice(struct torture_context *tctx,
                torture_skip(tctx, "leases are not supported");
        }
 
+       protocol = smbXcli_conn_protocol(tree->session->transport->conn);
+       if (protocol < PROTOCOL_SMB3_00) {
+               torture_skip(tctx, "v2 leases are not supported");
+       }
+
        smb2_util_unlink(tree, fname);
 
        ZERO_STRUCT(break_info);
@@ -1297,6 +1320,21 @@ static bool test_lease_v2_request(struct torture_context *tctx,
        const char *dnamefname = "lease.dir\\lease.dat";
        const char *dnamefname2 = "lease.dir\\lease2.dat";
        bool ret = true;
+       uint32_t caps;
+       enum protocol_types protocol;
+
+       caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
+       if (!(caps & SMB2_CAP_LEASING)) {
+               torture_skip(tctx, "leases are not supported");
+       }
+       if (!(caps & SMB2_CAP_DIRECTORY_LEASING)) {
+               torture_skip(tctx, "directory leases are not supported");
+       }
+
+       protocol = smbXcli_conn_protocol(tree->session->transport->conn);
+       if (protocol < PROTOCOL_SMB3_00) {
+               torture_skip(tctx, "v2 leases are not supported");
+       }
 
        smb2_util_unlink(tree, fname);
        smb2_deltree(tree, dname);
@@ -1427,6 +1465,18 @@ static bool test_lease_v2_epoch1(struct torture_context *tctx,
        const char *fname = "lease.dat";
        bool ret = true;
        NTSTATUS status;
+       uint32_t caps;
+       enum protocol_types protocol;
+
+       caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
+       if (!(caps & SMB2_CAP_LEASING)) {
+               torture_skip(tctx, "leases are not supported");
+       }
+
+       protocol = smbXcli_conn_protocol(tree->session->transport->conn);
+       if (protocol < PROTOCOL_SMB3_00) {
+               torture_skip(tctx, "v2 leases are not supported");
+       }
 
        smb2_util_unlink(tree, fname);