Пример #1
0
        public static void CreateResponse(ModelSmb2Status status, CreateCloseConfig c)
        {
            Condition.IsTrue(Config.Platform == c.Platform);
            Condition.IsTrue(State == ModelState.Connected);

            ModelCreateRequest createRequest = ModelHelper.RetrieveOutstandingRequest <ModelCreateRequest>(ref Request);

            if (createRequest.NameType == CreateFileNameType.StartWithPathSeparator)
            {
                ModelHelper.Log(LogType.Requirement, "3.3.5.9: If the file name length is greater than zero and the first character is a path separator character, the server MUST fail the request with STATUS_INVALID_PARAMETER.");
                ModelHelper.Log(LogType.TestInfo, "The first character in the file name of the Create Request is a path separator.");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                Condition.IsTrue(status == ModelSmb2Status.STATUS_INVALID_PARAMETER);
                return;
            }

            if (createRequest.NameType == CreateFileNameType.OtherInvalidFileName)
            {
                ModelHelper.Log(LogType.Requirement, "3.3.5.9: If the file name fails to conform with the specification of a relative pathname in [MS-FSCC] section 2.1.5, the server MUST fail the request with STATUS_OBJECT_NAME_INVALID.");
                ModelHelper.Log(LogType.TestInfo, "The file name of the Create Request contains illegal character.");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                Condition.IsTrue(status == ModelSmb2Status.STATUS_OBJECT_NAME_INVALID);
                return;
            }

            if (createRequest.ContextType == CreateContextType.InvalidCreateContext)
            {
                ModelHelper.Log(LogType.Requirement, "3.3.5.9: The server SHOULD fail any request having a create context not specified in section 2.2.13.2, with a STATUS_INVALID_PARAMETER error.");
                ModelHelper.Log(LogType.TestInfo, "The create context of Create Request is invalid");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedContext);
                if (Config.Platform != Platform.NonWindows)
                {
                    ModelHelper.Log(LogType.TestInfo, "The SUT platform is Windows");
                    Condition.IsTrue(status == ModelSmb2Status.STATUS_INVALID_PARAMETER);
                }
                else
                {
                    ModelHelper.Log(LogType.TestInfo, "The SUT platform is NonWindows");
                    Condition.IsTrue(status != ModelSmb2Status.STATUS_SUCCESS);
                }
                return;
            }

            // Create Context Validation:
            if (createRequest.ContextType == CreateContextType.InvalidCreateContextSize)
            {
                ModelHelper.Log(LogType.Requirement, "3.3.5.9: If the size of each individual create context is not equal to the DataLength of the create context, the server MUST fail the request with STATUS_INVALID_PARAMETER.");
                ModelHelper.Log(LogType.TestInfo, "The size of the create context in the Create Request is invalid.");
                ModelHelper.Log(LogType.TestTag, TestTag.OutOfBoundary);
                Condition.IsTrue(status == ModelSmb2Status.STATUS_INVALID_PARAMETER);
                return;
            }

            if (createRequest.ImpersonationType == ImpersonationLevelType.InvalidImpersonationLevel && Config.Platform != Platform.WindowsServer2008)
            {
                ModelHelper.Log(LogType.Requirement, "3.3.5.9: If the ImpersonationLevel in the request is not one of the values specified in section 2.2.13, the server SHOULD fail the request with STATUS_BAD_IMPERSONATION_LEVEL.");
                ModelHelper.Log(LogType.TestInfo, "The ImpersonationLevel of the Create Request is invalid.");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);

                // <236> Section 3.3.5.9: Windows Vista and Windows Server 2008 do not fail the request if the ImpersonationLevel in the request is not one of the values specified in section 2.2.13.
                if (Config.Platform != Platform.NonWindows)
                {
                    ModelHelper.Log(LogType.TestInfo, "The SUT platform is Windows");
                    Condition.IsTrue(status == ModelSmb2Status.STATUS_BAD_IMPERSONATION_LEVEL);
                }
                else
                {
                    ModelHelper.Log(LogType.TestInfo, "The SUT platform is NonWindows");
                    Condition.IsTrue(status != ModelSmb2Status.STATUS_SUCCESS);
                }
                return;
            }

            ModelHelper.Log(LogType.Requirement, "3.3.5.9: If the open is successful, the server MUST allocate an open object for this open and insert it into Session.OpenTable and GlobalOpenTable. ");
            ModelHelper.Log(LogType.TestInfo, "The Create Request doesn't contain any invalid fields, the open is created successfully and server should return STATUS_SUCCESS");
            Condition.IsTrue(status == ModelSmb2Status.STATUS_SUCCESS);
            HasOpen = true;
        }
        public async Task <ActionResult> Create()
        {
            string token_header = null;

            if (Session["token_header"] != null)
            {
                token_header = Session["token_header"].ToString();
            }

            CustomTranslatorAPIClient clientapp = new CustomTranslatorAPIClient();

            ModelCreateRequest model = new ModelCreateRequest(); // Create new object for Model and add values

            model.name        = "...";                           // Enter model name
            model.projectId   = "...";                           // Enter project id
            model.documentIds = new List <int>();
            model.documentIds.Add(...);                          // Add multiple documents using DocumentID. DocumentID is int.
            model.isTuningAuto        = true;                    // Enter if tuning set will be set to auto. values = true, false
            model.isTestingAuto       = true;                    // Enter if testing set will be set to auto. values = true, false
            model.isAutoDeploy        = false;                   // Enter if this model will be automatically deployed. values = true, false
            model.autoDeployThreshold = 0;                       // Enter the value of auto deploy threshold value

            string result = await clientapp.GetProject(model.projectId, token_header);

            Project project = getProjectDetail(result);

            result = await clientapp.CreateModel(token_header, model);

            string[] resultarray = result.Split('/');

            if (resultarray.Length > 1)
            {
                string newtrainingid = resultarray[resultarray.Length - 1];
                Response.Write("<br/>New Model Created");
                Response.Write("<br/>Model Id: " + newtrainingid);
                Response.Write("<br/>Model Name: " + model.name);
                Response.Write("<br/>Project Name: " + project.name);
                Response.Write("<br/>Language Pair: " + project.languagePair.sourceLanguage.displayName + " to " + project.languagePair.targetLanguage.displayName);
                foreach (int fileid in model.documentIds)
                {
                    result = await clientapp.GetDocument(fileid, token_header);

                    DocumentInfo doc = getDocumentDetail(result);
                    Response.Write("<br/>Document : " + doc.name);
                    int i = 1;
                    foreach (FileInDocument f in doc.files)
                    {
                        Response.Write("<br/>File " + i + " :");
                        Response.Write("<br/>File Name: " + f.fileName);
                        Response.Write("<br/>Language: " + f.language.displayName);
                        i++;
                    }
                }
            }
            else
            {
                Response.Write("<br/>Could not create project: " + result);
            }

            return(View());
        }