use of jenkins.plugins.nodejs.configfiles.NPMRegistry in project nodejs-plugin by jenkinsci.
the class NpmrcFileSupplyTest method test_supply_npmrc_with_registry.
@Test
public void test_supply_npmrc_with_registry() throws Exception {
StandardUsernameCredentials user = createUser("test-user-id", "myuser", "mypassword");
NPMRegistry privateRegistry = new NPMRegistry("https://private.organization.com/", user.getId(), null);
NPMRegistry officalRegistry = new NPMRegistry("https://registry.npmjs.org/", null, "@user1 user2");
Config config = createSetting("mytest", "email=guest@example.com", Arrays.asList(privateRegistry, officalRegistry));
FreeStyleBuild build = j.buildAndAssertSuccess(j.createFreeStyleProject());
FilePath npmrcFile = ConfigFileManager.provisionConfigFile(new ConfigFile(config.id, null, true), null, build, build.getWorkspace(), j.createTaskListener(), new ArrayList<String>(1));
assertTrue(npmrcFile.exists());
assertTrue(npmrcFile.length() > 0);
Npmrc npmrc = Npmrc.load(new File(npmrcFile.getRemote()));
assertTrue("Missing setting email", npmrc.contains("email"));
assertEquals("Unexpected value from settings email", "guest@example.com", npmrc.get("email"));
}
use of jenkins.plugins.nodejs.configfiles.NPMRegistry in project nodejs-plugin by jenkinsci.
the class JCasCTest method checkConfigFile.
private void checkConfigFile(Jenkins j) {
Config config = ConfigFiles.getByIdOrNull(j, "myconfigfile");
assertThat(config, instanceOf(NPMConfig.class));
NPMConfig npmConfig = (NPMConfig) config;
assertEquals("myComment", npmConfig.comment);
assertEquals("myContent", npmConfig.content);
assertEquals("myConfig", npmConfig.name);
List<NPMRegistry> registries = npmConfig.getRegistries();
Assert.assertTrue(registries.size() == 1);
NPMRegistry registry = registries.get(0);
assertTrue(registry.isHasScopes());
assertEquals("myScope", registry.getScopes());
assertEquals("registryUrl", registry.getUrl());
}
Aggregations