예제 #1
0
func (s *EnsurePasswordSuite) tearDownKey(c *gc.C, shouldBeDeleted bool) {
	err := s.k.DeleteValue(s.tempRegEntry)
	if shouldBeDeleted {
		c.Assert(err, gc.ErrorMatches, utils.NoSuchFileErrRegexp)
	} else {
		c.Assert(err, jc.ErrorIsNil)
	}
	s.k.Close()
	err = registry.DeleteKey(registry.LOCAL_MACHINE, s.tempRegKey[6:])
	c.Assert(err, jc.ErrorIsNil)
}
예제 #2
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
}
예제 #3
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)
	})
}
예제 #4
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)
	})
}
예제 #5
0
// tearDownFeatureFlags restores the old registry values
func (s *JujuOSEnvSuite) tearDownFeatureFlags(c *gc.C) {
	regKey := osenv.JujuRegistryKey[len(`HKLM:\`):]
	if s.regKeyExisted {
		k, err := registry.OpenKey(registry.LOCAL_MACHINE, regKey, registry.ALL_ACCESS)
		if s.regEntryExisted {
			err := k.SetStringValue(osenv.JujuFeatureFlagEnvKey, s.oldRegEntryValue)
			c.Assert(err, jc.ErrorIsNil)
		} else {
			err := k.DeleteValue(osenv.JujuFeatureFlagEnvKey)
			c.Assert(err, jc.ErrorIsNil)
		}
		err = k.Close()
		c.Assert(err, jc.ErrorIsNil)
	} else {
		err := registry.DeleteKey(registry.LOCAL_MACHINE, regKey)
		c.Assert(err, jc.ErrorIsNil)
	}

}
예제 #6
0
func (s *flagWinSuite) TearDownTest(c *gc.C) {
	s.k.DeleteValue("JUJU_TESTING_FEATURE")
	s.k.Close()
	registry.DeleteKey(registry.LOCAL_MACHINE, regKey[6:])
}