// Path: src/main/java/org/jenkinsci/plugins/github/GitHubPlugin.java
// public class GitHubPlugin extends Plugin {
//     /**
//      * Launched before plugin starts
//      * Adds alias for {@link GitHubPlugin} to simplify resulting xml.
//      */
//     public static void addXStreamAliases() {
//         Migrator.enableCompatibilityAliases();
//         Migrator.enableAliases();
//     }
// 
//     /**
//      * Launches migration after all extensions have been augmented as we need to ensure that the credentials plugin
//      * has been initialized.
//      * We need ensure that migrator will run after xstream aliases will be added.
//      * @see <a href="https://issues.jenkins-ci.org/browse/JENKINS-36446">JENKINS-36446</a>
//      */
//     @Initializer(after = InitMilestone.EXTENSIONS_AUGMENTED, before = InitMilestone.JOB_LOADED)
//     public static void runMigrator() throws Exception {
//         new Migrator().migrate();
//     }
// 
//     @Override
//     public void start() throws Exception {
//         addXStreamAliases();
//     }
// 
//     /**
//      * Shortcut method for getting instance of {@link GitHubPluginConfig}.
//      *
//      * @return configuration of plugin
//      */
//     @NonNull
//     public static GitHubPluginConfig configuration() {
//         return defaultIfNull(
//                 GitHubPluginConfig.all().get(GitHubPluginConfig.class),
//                 GitHubPluginConfig.EMPTY_CONFIG
//         );
//     }
// }
// 
// Path: src/test/java/org/jenkinsci/plugins/github/test/HookSecretHelper.java
// public static void storeSecret(final String secretText) {
//     storeSecretIn(Jenkins.getInstance().getDescriptorByType(GitHubPluginConfig.class), secretText);
// }


import org.jenkinsci.plugins.github.GitHubPlugin;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import static org.jenkinsci.plugins.github.test.HookSecretHelper.storeSecret;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
package org.jenkinsci.plugins.github.config;




/**
 * Test for storing hook secrets.
 */
@SuppressWarnings("deprecation")
public class HookSecretConfigTest {

    private static final String SECRET_INIT = "test";

    @Rule
    public JenkinsRule jenkinsRule = new JenkinsRule();

    private HookSecretConfig hookSecretConfig;

    @Before
    public void setup() {
        storeSecret(SECRET_INIT);
    }

    @Test
    public void shouldStoreNewSecrets() {
        storeSecret(SECRET_INIT);

        hookSecretConfig = GitHubPlugin.configuration().getHookSecretConfig();
        assertNotNull("Secret is persistent", hookSecretConfig.getHookSecret());
        assertTrue("Secret correctly stored", SECRET_INIT.equals(hookSecretConfig.getHookSecret().getPlainText()));
    }

    @Test
    public void shouldOverwriteExistingSecrets() {
        final String newSecret = "test2";
        storeSecret(newSecret);

// Path: src/main/java/org/jenkinsci/plugins/github/GitHubPlugin.java
// public class GitHubPlugin extends Plugin {
//     /**
//      * Launched before plugin starts
//      * Adds alias for {@link GitHubPlugin} to simplify resulting xml.
//      */
//     public static void addXStreamAliases() {
//         Migrator.enableCompatibilityAliases();
//         Migrator.enableAliases();
//     }
// 
//     /**
//      * Launches migration after all extensions have been augmented as we need to ensure that the credentials plugin
//      * has been initialized.
//      * We need ensure that migrator will run after xstream aliases will be added.
//      * @see <a href="https://issues.jenkins-ci.org/browse/JENKINS-36446">JENKINS-36446</a>
//      */
//     @Initializer(after = InitMilestone.EXTENSIONS_AUGMENTED, before = InitMilestone.JOB_LOADED)
//     public static void runMigrator() throws Exception {
//         new Migrator().migrate();
//     }
// 
//     @Override
//     public void start() throws Exception {
//         addXStreamAliases();
//     }
// 
//     /**
//      * Shortcut method for getting instance of {@link GitHubPluginConfig}.
//      *
//      * @return configuration of plugin
//      */
//     @NonNull
//     public static GitHubPluginConfig configuration() {
//         return defaultIfNull(
//                 GitHubPluginConfig.all().get(GitHubPluginConfig.class),
//                 GitHubPluginConfig.EMPTY_CONFIG
//         );
//     }
// }
// 
// Path: src/test/java/org/jenkinsci/plugins/github/test/HookSecretHelper.java
// public static void storeSecret(final String secretText) {
//     storeSecretIn(Jenkins.getInstance().getDescriptorByType(GitHubPluginConfig.class), secretText);
// }


// Path: src/test/java/org/jenkinsci/plugins/github/config/HookSecretConfigTest.java
import org.jenkinsci.plugins.github.GitHubPlugin;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import static org.jenkinsci.plugins.github.test.HookSecretHelper.storeSecret;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

package org.jenkinsci.plugins.github.config;




/**
 * Test for storing hook secrets.
 */
@SuppressWarnings("deprecation")
public class HookSecretConfigTest {

    private static final String SECRET_INIT = "test";

    @Rule
    public JenkinsRule jenkinsRule = new JenkinsRule();

    private HookSecretConfig hookSecretConfig;

    @Before
    public void setup() {
        storeSecret(SECRET_INIT);
    }

    @Test
    public void shouldStoreNewSecrets() {
        storeSecret(SECRET_INIT);

        hookSecretConfig = GitHubPlugin.configuration().getHookSecretConfig();
        assertNotNull("Secret is persistent", hookSecretConfig.getHookSecret());
        assertTrue("Secret correctly stored", SECRET_INIT.equals(hookSecretConfig.getHookSecret().getPlainText()));
    }

    @Test
    public void shouldOverwriteExistingSecrets() {
        final String newSecret = "test2";
        storeSecret(newSecret);

        hookSecretConfig = GitHubPlugin.configuration().getHookSecretConfig();