<fim-prefix>ibutes(Collections.singletonMap(FOLDER, "../a"));

            tfsMaterialConfig.validate(new ConfigSaveValidationContext(null));

            assertThat(tfsMaterialConfig.errors().on(FOLDER)).isEqualTo("Dest folder '../a' is not valid. It must be a sub-directory of the working folder.");
        }

        @Test
        void shouldEnsureUrlIsNotBlank() {
            tfsMaterialConfig.setUrl("");
            tfsMaterialConfig.validate(new ConfigSaveValidationContext(null));

            assertThat(tfsMaterialConfig.errors().on(ScmMaterialConfig.URL)).isEqualTo("URL cannot be blank");
        }

        @Test
        void shouldEnsureUrlIsNotNull() {
            tfsMaterialConfig.setUrl(null);

            tfsMaterialConfig.validate(new ConfigSaveValidationContext(null));

            assertThat(tfsMaterialConfig.errors().on(URL)).isEqualTo("URL cannot be blank");
        }

        @Test
        void rejectsObviouslyWrongURL() {
            assertTrue(validating(tfs("-url-not-starting-with-an-alphanumeric-character")).errors().containsKey(TfsMaterialConfig.URL));
            assertTrue(validating(tfs("_url-not-starting-with-an-alphanumeric-character")).errors().containsKey(TfsMaterialConfig.URL));
            assertTrue(validating(tfs("@url-not-starting-with-an-alphanumeric-character")).errors().containsKey(TfsMaterialConfig.URL));

            assertFalse(validating(tfs("url-starting-with-an-alphanumeric-character")).errors().containsKey(TfsMaterialConfig.URL));
            // BUG: CWE-77 Improper Neutralization of Special Elements used in a Command ('Command Injection')
            // 
            // FIXED:
 <fim-middle>           assertFalse(validating(tfs("#{url}")).errors().containsKey(TfsMaterialConfig.URL));
        }

        private TfsMaterialConfig validating(TfsMaterialConfig tfs) {
            tfs.validate(<fix-suffix>new ConfigSaveValidationContext(null));
            return tfs;
        }
    }

    @Test
    void shouldEncryptTfsPasswordAndMarkPasswordAsNull() throws Exception {
        TfsMaterialConfig materialConfig = tfs(null, new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "CORPORATE", "password", "walk_this_path");
        materialConfig.ensureEncrypted();

        Object passwordFieldValue = ReflectionUtil.getField(materialConfig, "password");
        assertThat(passwordFieldValue).isNull();
        assertThat(materialConfig.getPassword()).isEqualTo("password");
        assertThat(materialConfig.getEncryptedPassword()).isEqualTo(new GoCipher().encrypt("password"));
    }

    @Test
    void shouldDecryptTfsPassword() throws Exception {
        String encryptedPassword = new GoCipher().encrypt("plain-text-password");
        TfsMaterialConfig materialConfig = tfs(null, new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "CORPORATE", "secret", "walk_this_path");
   <|endoftext|>