Ejemplo n.º 1
0
        public static void SetupConnection(ModelDialectRevision maxSmbVersionClientSupported, ModelShareFlag shareFlag, ModelShareType shareType)
        {
            Condition.IsTrue(State == ModelState.Initialized);

            Open               = null;
            Request            = null;
            Connection_Dialect = DialectRevision.Smb2Unknown;

            Connection_Dialect = ModelHelper.DetermineNegotiateDialect(maxSmbVersionClientSupported, Config.MaxSmbVersionSupported);

            Share_ForceLevel2Oplock = shareFlag == ModelShareFlag.SMB2_SHAREFLAG_FORCE_LEVELII_OPLOCK;
            Share_Type_Include_STYPE_CLUSTER_SOFS = shareType == ModelShareType.STYPE_CLUSTER_SOFS;

            State = ModelState.Connected;
        }
        public static void SetupConnection(ModelDialectRevision maxSmbVersionClientSupported, ModelShareFlag shareFlag, ModelShareType shareType)
        {
            Condition.IsTrue(State == ModelState.Initialized);

            Open = null;
            Request = null;
            Connection_Dialect = DialectRevision.Smb2Unknown;

            Connection_Dialect = ModelHelper.DetermineNegotiateDialect(maxSmbVersionClientSupported, Config.MaxSmbVersionSupported);

            Share_ForceLevel2Oplock = shareFlag == ModelShareFlag.SMB2_SHAREFLAG_FORCE_LEVELII_OPLOCK;
            Share_Type_Include_STYPE_CLUSTER_SOFS = shareType == ModelShareType.STYPE_CLUSTER_SOFS;

            State = ModelState.Connected;
        }
Ejemplo n.º 3
0
        public static void RequestOplockAndOperateFileReturn(OplockLevel_Values grantedOplockLevel, OplockConfig c)
        {
            Condition.IsTrue(State == ModelState.Connected);
            Condition.IsNotNull(Request);

            ModelRequestOplockAndTriggerBreakRequest requestOplockAndTriggerBreakRequest = ModelHelper.RetrieveOutstandingRequest <ModelRequestOplockAndTriggerBreakRequest>(ref Request);

            Condition.IsTrue(Config.Platform == c.Platform);

            if (Share_ForceLevel2Oplock &&
                (requestOplockAndTriggerBreakRequest.RequestedOplockLevel == RequestedOplockLevel_Values.OPLOCK_LEVEL_BATCH ||
                 requestOplockAndTriggerBreakRequest.RequestedOplockLevel == RequestedOplockLevel_Values.OPLOCK_LEVEL_EXCLUSIVE))
            {
                ModelHelper.Log(LogType.Requirement,
                                "3.3.5.9: If TreeConnect.Share.ForceLevel2Oplock is TRUE, " +
                                "and RequestedOplockLevel is SMB2_OPLOCK_LEVEL_BATCH or SMB2_OPLOCK_LEVEL_EXCLUSIVE, " +
                                "the server SHOULD<245> set RequestedOplockLevel to SMB2_OPLOCK_LEVEL_II.");
                if (Config.Platform != Platform.NonWindows)
                {
                    ModelHelper.Log(LogType.TestInfo, "The SUT platform is Windows.");
                    Condition.IsTrue(grantedOplockLevel == OplockLevel_Values.OPLOCK_LEVEL_II);

                    // Skip following WBN which is for pre-Win8
                    // <226> Section 3.3.5.9: Windows Vista and Windows Server 2008 do not support the SMB2_SHAREFLAG_FORCE_LEVELII_OPLOCK flag
                    // and ignore  the TreeConnect.Share.ForceLevel2Oplock value.
                }
            }

            if (ModelUtility.IsSmb3xFamily(Connection_Dialect) &&
                Share_Type_Include_STYPE_CLUSTER_SOFS &&
                requestOplockAndTriggerBreakRequest.RequestedOplockLevel == RequestedOplockLevel_Values.OPLOCK_LEVEL_BATCH)
            {
                ModelHelper.Log(LogType.Requirement,
                                "3.3.5.9: If Connection.Dialect belongs to the SMB 3.x dialect family TreeConnect.Share.Type includes STYPE_CLUSTER_SOFS " +
                                "and the RequestedOplockLevel is SMB2_OPLOCK_LEVEL_BATCH, the server MUST set RequestedOplockLevel to SMB2_OPLOCK_LEVEL_II.");
                // The Oplock acquisition depends on underlying object store implemention specific
                // we may not garantee level2 would be always granted
                // Only assert it's not batch
                ModelHelper.Log(LogType.TestInfo, "All the above conditions are met.");
                Condition.IsTrue(grantedOplockLevel != OplockLevel_Values.OPLOCK_LEVEL_BATCH);
            }

            Open = new ModelOplockOpen();

            ModelHelper.Log(LogType.TestInfo, "Open.OplockLevel is set to SMB2_OPLOCK_LEVEL_NONE.");
            Open.OplockLevel = OplockLevel_Values.OPLOCK_LEVEL_NONE;

            ModelHelper.Log(LogType.TestInfo, "Open.OplockState is set to None.");
            Open.OplockState = OplockState.None;

            // Acquire Oplock from underlying object

            // If the underlying object store grants the oplock,
            // then Open.OplockState is set to Held and Open.OplockLevel is set to the level of the oplock acquired.
            if (grantedOplockLevel != OplockLevel_Values.OPLOCK_LEVEL_NONE)
            {
                ModelHelper.Log(LogType.TestInfo, "Open.OplockState is set to Held.");
                Open.OplockState = OplockState.Held;
                Open.OplockLevel = grantedOplockLevel;
            }
        }
        public static void RequestOplockAndOperateFileReturn(OplockLevel_Values grantedOplockLevel, OplockConfig c)
        {
            Condition.IsTrue(State == ModelState.Connected);
            Condition.IsNotNull(Request);

            ModelRequestOplockAndTriggerBreakRequest requestOplockAndTriggerBreakRequest = ModelHelper.RetrieveOutstandingRequest<ModelRequestOplockAndTriggerBreakRequest>(ref Request);

            Condition.IsTrue(Config.Platform == c.Platform);

            if (Share_ForceLevel2Oplock
                && (requestOplockAndTriggerBreakRequest.RequestedOplockLevel == RequestedOplockLevel_Values.OPLOCK_LEVEL_BATCH
                     || requestOplockAndTriggerBreakRequest.RequestedOplockLevel == RequestedOplockLevel_Values.OPLOCK_LEVEL_EXCLUSIVE))
            {
                ModelHelper.Log(LogType.Requirement,
                    "3.3.5.9: If TreeConnect.Share.ForceLevel2Oplock is TRUE, " +
                    "and RequestedOplockLevel is SMB2_OPLOCK_LEVEL_BATCH or SMB2_OPLOCK_LEVEL_EXCLUSIVE, " +
                    "the server SHOULD<245> set RequestedOplockLevel to SMB2_OPLOCK_LEVEL_II.");
                if (Config.Platform != Platform.NonWindows)
                {
                    ModelHelper.Log(LogType.TestInfo, "The SUT platform is Windows.");
                    Condition.IsTrue(grantedOplockLevel == OplockLevel_Values.OPLOCK_LEVEL_II);

                    // Skip following WBN which is for pre-Win8
                    // <226> Section 3.3.5.9: Windows Vista and Windows Server 2008 do not support the SMB2_SHAREFLAG_FORCE_LEVELII_OPLOCK flag
                    // and ignore  the TreeConnect.Share.ForceLevel2Oplock value.
                }
            }

            if (ModelUtility.IsSmb3xFamily(Connection_Dialect)
                && Share_Type_Include_STYPE_CLUSTER_SOFS
                && requestOplockAndTriggerBreakRequest.RequestedOplockLevel == RequestedOplockLevel_Values.OPLOCK_LEVEL_BATCH)
            {
                ModelHelper.Log(LogType.Requirement,
                    "3.3.5.9: If Connection.Dialect belongs to the SMB 3.x dialect family TreeConnect.Share.Type includes STYPE_CLUSTER_SOFS " +
                    "and the RequestedOplockLevel is SMB2_OPLOCK_LEVEL_BATCH, the server MUST set RequestedOplockLevel to SMB2_OPLOCK_LEVEL_II.");
                // The Oplock acquisition depends on underlying object store implemention specific
                // we may not garantee level2 would be always granted
                // Only assert it's not batch
                ModelHelper.Log(LogType.TestInfo, "All the above conditions are met.");
                Condition.IsTrue(grantedOplockLevel != OplockLevel_Values.OPLOCK_LEVEL_BATCH);
            }

            Open = new ModelOplockOpen();

            ModelHelper.Log(LogType.TestInfo, "Open.OplockLevel is set to SMB2_OPLOCK_LEVEL_NONE.");
            Open.OplockLevel = OplockLevel_Values.OPLOCK_LEVEL_NONE;

            ModelHelper.Log(LogType.TestInfo, "Open.OplockState is set to None.");
            Open.OplockState = OplockState.None;

            // Acquire Oplock from underlying object

            // If the underlying object store grants the oplock,
            // then Open.OplockState is set to Held and Open.OplockLevel is set to the level of the oplock acquired.
            if (grantedOplockLevel != OplockLevel_Values.OPLOCK_LEVEL_NONE)
            {
                ModelHelper.Log(LogType.TestInfo, "Open.OplockState is set to Held.");
                Open.OplockState = OplockState.Held;
                Open.OplockLevel = grantedOplockLevel;
            }
        }