Пример #1
0
func (s *EnsurePasswordSuite) setUpKey(c *gc.C) {
	k, exist, err := registry.CreateKey(registry.LOCAL_MACHINE, s.tempRegKey[6:], registry.ALL_ACCESS)
	// If we get in here it means cleanup failed at some point earlier
	if exist {
		err = registry.DeleteKey(registry.LOCAL_MACHINE, s.tempRegKey[6:])
		k, exist, err = registry.CreateKey(registry.LOCAL_MACHINE, s.tempRegKey[6:], registry.ALL_ACCESS)
	}
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(exist, jc.IsFalse)
	s.k = k
}
Пример #2
0
func (s *windowsSeriesSuite) createRegKey(c *gc.C, key *string) {
	salt, err := utils.RandomPassword()
	c.Assert(err, jc.ErrorIsNil)
	regKey := fmt.Sprintf(`SOFTWARE\JUJU\%s`, salt)
	s.PatchValue(key, regKey)

	k, _, err := registry.CreateKey(registry.LOCAL_MACHINE, *key, registry.ALL_ACCESS)
	c.Assert(err, jc.ErrorIsNil)

	err = k.Close()
	c.Assert(err, jc.ErrorIsNil)

	s.AddCleanup(func(*gc.C) {
		registry.DeleteKey(registry.LOCAL_MACHINE, *series.CurrentVersionKey)
	})
}
Пример #3
0
func (s *windowsVersionSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)
	salt, err := utils.RandomPassword()
	c.Assert(err, jc.ErrorIsNil)
	regKey := fmt.Sprintf(`SOFTWARE\JUJU\%s`, salt)
	s.PatchValue(version.CurrentVersionKey, regKey)

	k, _, err := registry.CreateKey(registry.LOCAL_MACHINE, *version.CurrentVersionKey, registry.ALL_ACCESS)
	c.Assert(err, jc.ErrorIsNil)

	err = k.Close()
	c.Assert(err, jc.ErrorIsNil)

	s.AddCleanup(func(*gc.C) {
		registry.DeleteKey(registry.LOCAL_MACHINE, *version.CurrentVersionKey)
	})
}
Пример #4
0
// setUpFeatureFlags sets the feature flags from the environment, but
// also sets up the registry key on windows because some functions are
// trying to look in there.
func (s *JujuOSEnvSuite) setUpFeatureFlags(c *gc.C) {
	regKey := osenv.JujuRegistryKey[len(`HKLM:\`):]
	k, existed, err := registry.CreateKey(registry.LOCAL_MACHINE, regKey, registry.ALL_ACCESS)
	s.regKeyExisted = existed
	c.Assert(err, jc.ErrorIsNil)
	val, _, err := k.GetStringValue(osenv.JujuFeatureFlagEnvKey)
	if errors.Cause(err) == registry.ErrNotExist {
		s.regEntryExisted = false
	} else {
		c.Assert(err, jc.ErrorIsNil)
		s.oldRegEntryValue = val
		s.regEntryExisted = true
	}
	err = k.SetStringValue(osenv.JujuFeatureFlagEnvKey, s.initialFeatureFlags)
	c.Assert(err, jc.ErrorIsNil)
	featureflag.SetFlagsFromRegistry(osenv.JujuRegistryKey, osenv.JujuFeatureFlagEnvKey)
	err = k.Close()
	c.Assert(err, jc.ErrorIsNil)

}
Пример #5
0
func (s *flagWinSuite) SetUpTest(c *gc.C) {
	k, _, err := registry.CreateKey(registry.LOCAL_MACHINE, regKey[6:], registry.ALL_ACCESS)
	c.Assert(err, jc.ErrorIsNil)
	s.k = k
}