コード例 #1
0
        private ClientData DoCreateClient(ClientIdType type,
                                          TransportType transType,
                                          string id, int port,
                                          string name, string pipe,
                                          string appPath, string logPath,
                                          int timeout, bool mail, bool logAttach,
                                          bool restart, int queueSize)
        {
            // Creacion del objeto
            ClientData newClt = new ClientData()
            {
                IdType           = type,
                TransportType    = transType,
                Id               = id,
                Port             = port,
                Name             = name,
                Pipe             = pipe,
                AppFilePath      = appPath,
                LogFilePath      = logPath,
                Timeout          = timeout,
                MailEnabled      = mail,
                LogAttachEnabled = logAttach,
                RestartEnabled   = restart,
                QueueSize        = queueSize
            };


            Add(newClt);

            return(newClt);
        }
コード例 #2
0
        public void ReconnectOpenRequest(
            DurableV1ReconnectContext durableV1ReconnectContext,
            DurableV2ReconnectContext durableV2ReconnectContext,
            OplockLeaseType oplockLeaseType,
            LeaseKeyDifferentialType leaseKeyDifferentialType,
            ClientIdType clientIdType,
            CreateGuidType createGuidType)
        {
            if ((oplockLeaseType == OplockLeaseType.LeaseV1 || oplockLeaseType == OplockLeaseType.LeaseV2) &&
                !testConfig.IsLeasingSupported)
            {
                Site.Assert.Inconclusive("Test case is applicable in servers that support leasing.");
            }

            bool isSameLeaseKey   = (leaseKeyDifferentialType == LeaseKeyDifferentialType.SameLeaseKey);
            bool isSameClient     = (clientIdType == ClientIdType.SameClient);
            bool isSameCreateGuid = (createGuidType == CreateGuidType.SameCreateGuid);

            FILEID fileIdAfterDisconnection;

            Smb2CreateContextResponse[] serverCreateContexts;
            IPAddress targetIPAddress;
            string    targetServer;
            string    targetShare;

            #region Construct Create Contexts
            Smb2CreateContextRequest[] smb2CreateContextRequest = GetOpenFileCreateContext(
                DurableV1RequestContext.DurableV1RequestContextNotExist,
                DurableV2RequestContext.DurableV2RequestContextNotExist,
                durableV1ReconnectContext,
                durableV2ReconnectContext,
                oplockLeaseType,
                isSameLeaseKey,
                isSameCreateGuid);
            #endregion

            #region Client reconnect to server

            Site.Log.Add(LogEntryKind.Debug, "Client reconnect to server");

            #region Reconnect to Common Share or CA Share
            if (!isCAShare)
            {
                targetIPAddress = testConfig.SutIPAddress;
                targetServer    = testConfig.SutComputerName;
                targetShare     = testConfig.BasicFileShare;
            }
            else
            {
                targetIPAddress = testConfig.CAShareServerIP;
                targetServer    = testConfig.CAShareServerName;
                targetShare     = testConfig.CAShareName;
            }

            // Connect to Server
            testClientAfterDisconnection            = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site);
            testClientAfterDisconnection.CreditGoal = 10;
            testClientAfterDisconnection.ConnectToServer(testConfig.UnderlyingTransport, targetServer, targetIPAddress);

            // Negotiate
            testClientAfterDisconnection.Negotiate(
                requestDialect,
                testConfig.IsSMB1NegotiateEnabled,
                capabilityValue: clientCapabilities,
                // If the reconnect use the same client guid, then keep client guid the same value, otherwise use a new client guid.
                clientGuid: (isSameClient ? clientGuid : Guid.NewGuid()));

            uint status = testClientAfterDisconnection.SessionSetup(
                testConfig.DefaultSecurityPackage,
                targetServer,
                testConfig.AccountCredential,
                testConfig.UseServerGssToken);
            Site.Assert.AreEqual(Smb2Status.STATUS_SUCCESS, status, "Reconnect Session Setup should be successful, actual status is {0}", Smb2Status.GetStatusCode(status));

            // TreeConnect
            testClientAfterDisconnection.TreeConnect(sharePath, out treeIdAfterDisconnection);

            #endregion

            #region Send Create request according to different context combination

            RequestedOplockLevel_Values requestedOplockLevel = RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE;
            switch (oplockLeaseType)
            {
            case OplockLeaseType.NoOplockOrLease:
            {
                requestedOplockLevel = RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE;
            }
            break;

            case OplockLeaseType.BatchOplock:
            {
                requestedOplockLevel = RequestedOplockLevel_Values.OPLOCK_LEVEL_BATCH;
            }
            break;

            case OplockLeaseType.LeaseV1:
            case OplockLeaseType.LeaseV2:
            {
                requestedOplockLevel = RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE;
            }
            break;
            }

            status = OpenCreate(
                testClientAfterDisconnection,
                treeIdAfterDisconnection,
                fileName,
                out fileIdAfterDisconnection,
                out serverCreateContexts,
                requestedOplockLevel,
                smb2CreateContextRequest);

            #endregion

            DurableHandleResponseContext durableHandleResponse;
            LeaseResponseContext         leaseResponse;
            CheckResponseContexts(serverCreateContexts, out durableHandleResponse, out leaseResponse);
            OpenResponse((ModelSmb2Status)status, durableHandleResponse, leaseResponse, handleConfig);

            testClientAfterDisconnection.TreeDisconnect(treeIdAfterDisconnection);
            testClientAfterDisconnection.LogOff();

            #endregion
        }
コード例 #3
0
        public void ReconnectOpenRequest(
            DurableV1ReconnectContext durableV1ReconnectContext,
            DurableV2ReconnectContext durableV2ReconnectContext,
            OplockLeaseType oplockLeaseType,
            LeaseKeyDifferentialType leaseKeyDifferentialType,
            ClientIdType clientIdType,
            CreateGuidType createGuidType)
        {
            if ((oplockLeaseType == OplockLeaseType.LeaseV1 || oplockLeaseType == OplockLeaseType.LeaseV2)
                && !testConfig.IsLeasingSupported)
                Site.Assert.Inconclusive("Test case is applicable in servers that support leasing.");

            bool isSameLeaseKey = (leaseKeyDifferentialType == LeaseKeyDifferentialType.SameLeaseKey);
            bool isSameClient = (clientIdType == ClientIdType.SameClient);
            bool isSameCreateGuid = (createGuidType == CreateGuidType.SameCreateGuid);

            FILEID fileIdAfterDisconnection;
            Smb2CreateContextResponse[] serverCreateContexts;
            IPAddress targetIPAddress;
            string targetServer;
            string targetShare;

            #region Construct Create Contexts
            Smb2CreateContextRequest[] smb2CreateContextRequest = GetOpenFileCreateContext(
                DurableV1RequestContext.DurableV1RequestContextNotExist,
                DurableV2RequestContext.DurableV2RequestContextNotExist,
                durableV1ReconnectContext,
                durableV2ReconnectContext,
                oplockLeaseType,
                isSameLeaseKey,
                isSameCreateGuid);
            #endregion

            #region Client reconnect to server

            Site.Log.Add(LogEntryKind.Debug, "Client reconnect to server");

            #region Reconnect to Common Share or CA Share
            if (!isCAShare)
            {
                targetIPAddress = testConfig.SutIPAddress;
                targetServer = testConfig.SutComputerName;
                targetShare = testConfig.BasicFileShare;
            }
            else
            {
                targetIPAddress = testConfig.CAShareServerIP;
                targetServer = testConfig.CAShareServerName;
                targetShare = testConfig.CAShareName;
            }

            // Connect to Server
            testClientAfterDisconnection = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site);
            testClientAfterDisconnection.CreditGoal = 10;
            testClientAfterDisconnection.ConnectToServer(testConfig.UnderlyingTransport, targetServer, targetIPAddress);

            // Negotiate
            testClientAfterDisconnection.Negotiate(
                requestDialect,
                testConfig.IsSMB1NegotiateEnabled,
                capabilityValue: clientCapabilities,
                // If the reconnect use the same client guid, then keep client guid the same value, otherwise use a new client guid.
                clientGuid: (isSameClient ? clientGuid : Guid.NewGuid()));

            uint status = testClientAfterDisconnection.SessionSetup(
                testConfig.DefaultSecurityPackage,
                targetServer,
                testConfig.AccountCredential,
                testConfig.UseServerGssToken);
            Site.Assert.AreEqual(Smb2Status.STATUS_SUCCESS, status, "Reconnect Session Setup should be successful, actual status is {0}", Smb2Status.GetStatusCode(status));

            // TreeConnect
            testClientAfterDisconnection.TreeConnect(sharePath, out treeIdAfterDisconnection);

            #endregion

            #region Send Create request according to different context combination

            RequestedOplockLevel_Values requestedOplockLevel = RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE;
            switch (oplockLeaseType)
            {
                case OplockLeaseType.NoOplockOrLease:
                    {
                        requestedOplockLevel = RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE;
                    }
                    break;

                case OplockLeaseType.BatchOplock:
                    {
                        requestedOplockLevel = RequestedOplockLevel_Values.OPLOCK_LEVEL_BATCH;
                    }
                    break;

                case OplockLeaseType.LeaseV1:
                case OplockLeaseType.LeaseV2:
                    {
                        requestedOplockLevel = RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE;
                    }
                    break;
            }

            status = OpenCreate(
                testClientAfterDisconnection,
                treeIdAfterDisconnection,
                fileName,
                out fileIdAfterDisconnection,
                out serverCreateContexts,
                requestedOplockLevel,
                smb2CreateContextRequest);

            #endregion

            DurableHandleResponseContext durableHandleResponse;
            LeaseResponseContext leaseResponse;
            CheckResponseContexts(serverCreateContexts, out durableHandleResponse, out leaseResponse);
            OpenResponse((ModelSmb2Status)status, durableHandleResponse, leaseResponse, handleConfig);

            testClientAfterDisconnection.TreeDisconnect(treeIdAfterDisconnection);
            testClientAfterDisconnection.LogOff();

            #endregion
        }
コード例 #4
0
        public static void ReconnectOpenRequest(
            DurableV1ReconnectContext durableV1ReconnectContext,
            DurableV2ReconnectContext durableV2ReconnectContext,
            OplockLeaseType oplockLeaseType,
            LeaseKeyDifferentialType leaseKeyDifferentialType,
            ClientIdType clientIdType,
            CreateGuidType createGuidType)
        {
            // If lease does not exist, LeaseKeyDifferentialType and LeaseStateDifferentialType take no effect. So just fix their values.
            Condition.IfThen(oplockLeaseType != OplockLeaseType.LeaseV1 && oplockLeaseType != OplockLeaseType.LeaseV2,
                leaseKeyDifferentialType == LeaseKeyDifferentialType.SameLeaseKey);

            // If there is no durablev2 reconnect context, fix the value of CreateGuid.
            Condition.IfThen(durableV2ReconnectContext == DurableV2ReconnectContext.DurableV2ReconnectContextNotExist, createGuidType == CreateGuidType.SameCreateGuid);

            // Do not need to test the situation of both V1 and V2 reconnect contexts not existed.
            Condition.IsFalse(durableV1ReconnectContext == DurableV1ReconnectContext.DurableV1ReconnectContextNotExist
                && durableV2ReconnectContext == DurableV2ReconnectContext.DurableV2ReconnectContextNotExist);

            // Only the server implements the SMB 2.1 or SMB 3.x dialect family supports leasing
            Condition.IfThen(NegotiateDialect == DialectRevision.Smb2002, oplockLeaseType != OplockLeaseType.LeaseV1 && oplockLeaseType != OplockLeaseType.LeaseV2);

            // Lease V2 is only vaild for SMB 3.x dialect family.
            Condition.IfThen(NegotiateDialect == DialectRevision.Smb21, oplockLeaseType != OplockLeaseType.LeaseV2);

            // If leasing is not supported, do not test LeaseV1 or LeaseV2.
            Condition.IfThen(!Config.IsLeasingSupported,
                oplockLeaseType != OplockLeaseType.LeaseV1 && oplockLeaseType != OplockLeaseType.LeaseV2);

            // 3.3.5.9.10, 3.3.5.9.12   This section applies only to servers that implement the SMB 3.x dialect family.
            Condition.IfThen(!ModelUtility.IsSmb3xFamily(Config.MaxSmbVersionSupported), durableV2ReconnectContext == DurableV2ReconnectContext.DurableV2ReconnectContextNotExist);

            // Add restriction to limit the generated cases of model.
            Combination.Pairwise(durableV1ReconnectContext, durableV2ReconnectContext, oplockLeaseType, leaseKeyDifferentialType, clientIdType, createGuidType);

            Condition.IsNull(Request);
            Request = new ModelOpenFileRequest(
                DurableV1RequestContext.DurableV1RequestContextNotExist,
                DurableV2RequestContext.DurableV2RequestContextNotExist,
                durableV1ReconnectContext,
                durableV2ReconnectContext,
                oplockLeaseType,
                leaseKeyDifferentialType == LeaseKeyDifferentialType.SameLeaseKey,
                clientIdType == ClientIdType.SameClient,
                createGuidType == CreateGuidType.SameCreateGuid);
        }
コード例 #5
0
        // Creacion de cliente
        // Creador de clientes Pipe

        // Nuevo creador de clientes Udp
        public ClientData CreateClient(ClientIdType type,
                                       TransportType transType,
                                       string id, int port,
                                       string name, string pipe,
                                       string appPath, string logPath,
                                       int timeout, bool mail, bool logAttach,
                                       bool restart, int queueSize)
        {
            // Validacion de parametros
            // Claves
            if (type == ClientIdType.KeyByIdString)
            {
                // Clave ID
                if (string.IsNullOrEmpty(id))
                {
                    throw new ArgumentException("El valor no puede ser nulo.", "id");
                }

                if (ContainsId(id))
                {
                    throw new ArgumentException("El valor ya está registrado.", "id");
                }
            }

            if (type == ClientIdType.KeyByUdpPort)
            {
                if (port == 0)
                {
                    throw new ArgumentException("El valor no puede ser cero.", "port");
                }

                if (port < 1024 || port > 65535)
                {
                    throw new ArgumentOutOfRangeException("port", "El  valor debe estar entre 1024 y 65535.");
                }

                if (ContainsPort(port))
                {
                    throw new ArgumentException("El valor ya está registrado.", "port");
                }
            }

            if (type == ClientIdType.KeyByPipe)
            {
                // Clave Pipe
                if (string.IsNullOrEmpty(pipe))
                {
                    throw new ArgumentException("El valor no puede ser nulo.", "pipe");
                }

                if (ContainsPipe(pipe))
                {
                    throw new ArgumentException("El valor ya está registrado.", "pipe");
                }

                // Si el puerto NO es clave, puede ser cero. Si es distinto de cero, debe
                // estar en el rango libre
                if (port != 0 && (port < 1024 || port > 65535))
                {
                    throw new ArgumentOutOfRangeException("port", "El  valor debe estar entre 1024 y 65535.");
                }
            }

            // name
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name", "El valor no puede ser nulo.");
            }
            if (ContainsName(name))
            {
                throw new ArgumentException("El valor ya está registrado.", "name");
            }

            // Resto de los campos
            // appPath
            if (string.IsNullOrEmpty(appPath))
            {
                throw new ArgumentNullException("appPath", "El valor no puede ser nulo.");
            }
            // logPath
            if (string.IsNullOrEmpty(logPath))
            {
                throw new ArgumentNullException("logPath", "El valor no puede ser nulo.");
            }
            // timeout
            if (timeout == 0)
            {
                throw new ArgumentException("El valor no puede ser cero.", "timeout");
            }
            // queueSize
            if (queueSize == 0)
            {
                throw new ArgumentException("El valor no puede ser cero.", "queueSize");
            }

            // Invocar creador real
            return(DoCreateClient(type, transType, id, port, name, pipe, appPath, logPath, timeout, mail, logAttach, restart, queueSize));
        }
コード例 #6
0
        // Creacion de cliente
        // Nuevo creador de clientes
        public ClientData CreateClient(ClientIdType type,
                                       string id,
                                       int port,
                                       string name,
                                       string appPath, string logPath,
                                       int timeout, bool mail, bool logAttach, int queueSize)
        {
            // Validacion de parametros
            // Claves
            if (type == ClientIdType.KeyByIdString)
            {
                // Clave ID
                if (string.IsNullOrEmpty(id))
                {
                    throw new ArgumentException("El valor no puede ser nulo.", "id");
                }

                if (ContainsId(id))
                {
                    throw new ArgumentException("El valor ya está registrado.", "id");
                }

                // Si el puerto NO es clave, puede ser cero. Si es distinto de cero, debe
                // estar en el rango libre
                if (port != 0 && (port < 1024 || port > 65535))
                {
                    throw new ArgumentOutOfRangeException("port", "El  valor debe estar entre 1024 y 65535.");
                }
            }
            else
            {
                // Clave Puerto
                if (port == 0)
                {
                    throw new ArgumentException("El valor no puede ser cero.", "port");
                }

                if (port < 1024 || port > 65535)
                {
                    throw new ArgumentOutOfRangeException("port", "El  valor debe estar entre 1024 y 65535.");
                }

                if (ContainsPort(port))
                {
                    throw new ArgumentException("El valor ya está registrado.", "port");
                }
            }
            // name
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name", "El valor no puede ser nulo.");
            }
            if (ContainsName(name))
            {
                throw new ArgumentException("El valor ya está registrado.", "name");
            }

            // Resto de los campos
            // appPath
            if (string.IsNullOrEmpty(appPath))
            {
                throw new ArgumentNullException("appPath", "El valor no puede ser nulo.");
            }
            // logPath
            if (string.IsNullOrEmpty(logPath))
            {
                throw new ArgumentNullException("logPath", "El valor no puede ser nulo.");
            }
            // timeout
            if (timeout == 0)
            {
                throw new ArgumentException("El valor no puede ser cero.", "timeout");
            }
            // queueSize
            if (queueSize == 0)
            {
                throw new ArgumentException("El valor no puede ser cero.", "queueSize");
            }

            // Creacion del objeto
            ClientData newClt = new ClientData();

            newClt.IdType           = type;
            newClt.Id               = id;
            newClt.Port             = port;
            newClt.Name             = name;
            newClt.AppFilePath      = appPath;
            newClt.LogFilePath      = logPath;
            newClt.Timeout          = timeout;
            newClt.MailEnabled      = mail;
            newClt.LogAttachEnabled = logAttach;
            newClt.QueueSize        = queueSize;

            Add(newClt);

            return(newClt);
        }