<fim-prefix>terialConfig = git("http://bob:pass@example.com##dobule-hash-is-invalid-in-url");
            gitMaterialConfig.setUserName("user");
            gitMaterialConfig.setPassword("password");

            assertFalse(validating(gitMaterialConfig).errors().containsKey(GitMaterialConfig.URL));
        }

        @Test
        void shouldBeValidWhenCredentialsAreProvidedOnlyInUrl() {
            assertFalse(validating(git("http://bob:pass@example.com")).errors().containsKey(GitMaterialConfig.URL));
        }

        @Test
        void shouldBeValidWhenCredentialsAreProvidedOnlyAsAttributes() {
            GitMaterialConfig gitMaterialConfig = git("http://example.com");
            gitMaterialConfig.setUserName("bob");
            gitMaterialConfig.setPassword("badger");

            assertFalse(validating(gitMaterialConfig).errors().containsKey(GitMaterialConfig.URL));
        }

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

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

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

    @Nested
    class ValidateTree {
        @Test
        void shouldCallValidate() {
            final MaterialConfig materialConfig = spy(git("https://example.repo"));
            final ValidationContext validationContext = mockValidationContextForSecretParams();

            materialConfig.validateTree(validationContext);

            verify(materialConfig).validate(validationContext);
        }

        @Test
        void shouldFailIfEncryptedPasswordIsIncorrect() {
            GitMaterialConfig gitMaterialConfig = git("http://example.com");
            gitMaterialConfig.setEncryptedPassword("encryptedPassword");

            final boolean validationResult = gitMaterialConfig.validateTree(new ConfigSaveValidationContext(null));

            assertFalse(validationResult);
            assertEquals("Encrypted password value for GitMaterial with url 'http://example.com' is " +
                            <|endoftext|>