-
Notifications
You must be signed in to change notification settings - Fork 45
Upgrade to new jcasc test harness #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,80 +5,29 @@ | |
| import com.cloudbees.plugins.credentials.domains.Domain; | ||
| import hudson.model.Item; | ||
| import hudson.security.ACL; | ||
| import jenkins.model.Jenkins; | ||
| import org.apache.commons.io.FileUtils; | ||
| import org.junit.Before; | ||
| import org.junit.ClassRule; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.rules.TemporaryFolder; | ||
| import org.jvnet.hudson.test.JenkinsRule; | ||
|
|
||
| import java.io.File; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import org.jvnet.hudson.test.recipes.LocalData; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertNotNull; | ||
|
|
||
| public class CredentialRenameTest { | ||
| public static File input = new File("src/test/resources/com/microsoftopentechnologies/helper/correctFormatOldConfig.xml"); | ||
gavinfish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private Jenkins jenkinsInstance; | ||
| private static final String correctConfigContent = | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on new credentials it seems like the credential.xml was cached in memory and credentials weren't being loaded by just overwriting it on the file system |
||
| "<?xml version='1.0' encoding='UTF-8'?>\n" + | ||
| "<com.cloudbees.plugins.credentials.SystemCredentialsProvider plugin=\"[email protected]\">\n" + | ||
| " <domainCredentialsMap class=\"hudson.util.CopyOnWriteMap$Hash\">\n" + | ||
| " <entry>\n" + | ||
| " <com.cloudbees.plugins.credentials.domains.Domain>\n" + | ||
| " <specifications/>\n" + | ||
| " </com.cloudbees.plugins.credentials.domains.Domain>\n" + | ||
| " <java.util.concurrent.CopyOnWriteArrayList>\n" + | ||
| " <com.microsoftopentechnologies.windowsazurestorage.helper.AzureCredentials plugin=\"[email protected]\">\n" + | ||
| " <scope>GLOBAL</scope>\n" + | ||
| " <id>jieshestorage</id>\n" + | ||
| " <description></description>\n" + | ||
| " <storageData>\n" + | ||
| " <storageAccountName>name</storageAccountName>\n" + | ||
| " <storageAccountKey>key</storageAccountKey>\n" + | ||
| " <blobEndpointURL>https://blob.core.windows.net/</blobEndpointURL>\n" + | ||
| " </storageData>\n" + | ||
| " </com.microsoftopentechnologies.windowsazurestorage.helper.AzureCredentials>\n" + | ||
| " </java.util.concurrent.CopyOnWriteArrayList>\n" + | ||
| " </entry>\n" + | ||
| " </domainCredentialsMap>\n" + | ||
| "</com.cloudbees.plugins.credentials.SystemCredentialsProvider>"; | ||
|
|
||
| private static final String wrongConfigContent = "<?xml version='1.0' encoding='UTF-8'?>\n" + | ||
gavinfish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "<com.microsoftopentechnologies.windowsazurestorage.AzureStoragePublisher_-WAStorageDescriptor plugin='[email protected]'>\n" + | ||
| "<storageAccounts>\n" + | ||
| "<storageAccName>abcdef</storageAccName>\n" + | ||
| "<storageAccountKey>12345</storageAccountKey>\n" + | ||
| "<blobEndPointURL>https://blob.core.windows.net/</blobEndPointURL>\n" + | ||
| "</storageAccounts>\n" + | ||
| "</com.microsoftopentechnologies.windowsazurestorage.AzureStoragePublisher_-WAStorageDescriptor>"; | ||
|
|
||
| @Rule | ||
| public TemporaryFolder testFolder = new TemporaryFolder(); | ||
| @ClassRule | ||
| public static JenkinsRule j = new JenkinsRule(); | ||
|
|
||
| @Before | ||
| public void setUp() { | ||
| jenkinsInstance = Jenkins.getInstance(); | ||
| } | ||
| public JenkinsRule j = new JenkinsRule(); | ||
|
|
||
| @Test | ||
| @LocalData | ||
| public void testRenameStorageConfig() throws Exception { | ||
| String storageAccount = "name"; | ||
| String storageAccountKey = "key"; | ||
| String storageBlobURL = "https://blob.core.windows.net/"; | ||
| File configFile = testFolder.newFile("credentials.xml"); | ||
| FileUtils.writeStringToFile(configFile, correctConfigContent); | ||
| FileUtils.copyFileToDirectory(configFile, jenkinsInstance.root); | ||
|
|
||
| CredentialRename.renameStorageConfig(); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is called on startup, no need to call it again |
||
|
|
||
| CredentialsStore s = CredentialsProvider.lookupStores(jenkinsInstance).iterator().next(); | ||
| CredentialsStore s = CredentialsProvider.lookupStores(j.jenkins).iterator().next(); | ||
|
|
||
| assertEquals(1, s.getCredentials(Domain.global()).size()); | ||
|
|
||
|
|
@@ -96,6 +45,5 @@ public void testRenameStorageConfig() throws Exception { | |
| assertEquals(u.getStorageAccountName(), storageCred.getStorageAccountName()); | ||
| assertEquals(u.getEndpointURL(), storageCred.getBlobEndpointURL()); | ||
| assertEquals(u.getSecureKey().getPlainText(), storageCred.getPlainStorageKey()); | ||
|
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?xml version='1.0' encoding='UTF-8'?> | ||
| <com.cloudbees.plugins.credentials.SystemCredentialsProvider plugin="[email protected]"> | ||
| <domainCredentialsMap class="hudson.util.CopyOnWriteMap$Hash"> | ||
| <entry> | ||
| <com.cloudbees.plugins.credentials.domains.Domain> | ||
| <specifications/> | ||
| </com.cloudbees.plugins.credentials.domains.Domain> | ||
| <java.util.concurrent.CopyOnWriteArrayList> | ||
| <com.microsoftopentechnologies.windowsazurestorage.helper.AzureCredentials | ||
| plugin="[email protected]"> | ||
| <scope>GLOBAL</scope> | ||
| <id>jieshestorage</id> | ||
| <description></description> | ||
| <storageData> | ||
| <storageAccountName>name</storageAccountName> | ||
| <storageAccountKey>key</storageAccountKey> | ||
| <blobEndpointURL>https://blob.core.windows.net/</blobEndpointURL> | ||
| </storageData> | ||
| </com.microsoftopentechnologies.windowsazurestorage.helper.AzureCredentials> | ||
| </java.util.concurrent.CopyOnWriteArrayList> | ||
| </entry> | ||
| </domainCredentialsMap> | ||
| </com.cloudbees.plugins.credentials.SystemCredentialsProvider> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The credentials configurator moved to the credentials plugin from the support plugin in this version