Beispiel #1
0
func (s *charmsSuite) TestUploadBumpsRevision(c *gc.C) {
	// Add the dummy charm with revision 1.
	ch := charmtesting.Charms.Bundle(c.MkDir(), "dummy")
	curl := charm.MustParseURL(
		fmt.Sprintf("local:quantal/%s-%d", ch.Meta().Name, ch.Revision()),
	)
	bundleURL, err := url.Parse("http://bundles.testing.invalid/dummy-1")
	c.Assert(err, gc.IsNil)
	_, err = s.State.AddCharm(ch, curl, bundleURL, "dummy-1-sha256")
	c.Assert(err, gc.IsNil)

	// Now try uploading the same revision and verify it gets bumped,
	// and the BundleURL and BundleSha256 are calculated.
	resp, err := s.uploadRequest(c, s.charmsURI(c, "?series=quantal"), true, ch.Path)
	c.Assert(err, gc.IsNil)
	expectedURL := charm.MustParseURL("local:quantal/dummy-2")
	s.assertUploadResponse(c, resp, expectedURL.String())
	sch, err := s.State.Charm(expectedURL)
	c.Assert(err, gc.IsNil)
	c.Assert(sch.URL(), gc.DeepEquals, expectedURL)
	c.Assert(sch.Revision(), gc.Equals, 2)
	c.Assert(sch.IsUploaded(), jc.IsTrue)
	// No more checks for these two here, because they
	// are verified in TestUploadRespectsLocalRevision.
	c.Assert(sch.BundleURL(), gc.Not(gc.Equals), "")
	c.Assert(sch.BundleSha256(), gc.Not(gc.Equals), "")
}
Beispiel #2
0
func (*testWrapper) TestGetAutoLoginUser(c *C.C) {
	name, err := getLightdmAutoLoginUser("testdata/autologin/lightdm_autologin.conf")
	c.Check(err, C.Equals, nil)
	c.Check(name, C.Equals, "wen")
	name, err = getLightdmAutoLoginUser("testdata/autologin/lightdm.conf")
	c.Check(err, C.Equals, nil)
	c.Check(name, C.Equals, "")
	_, err = getLightdmAutoLoginUser("testdata/autologin/xxxxx.conf")
	c.Check(err, C.Not(C.Equals), nil)

	name, err = getGDMAutoLoginUser("testdata/autologin/custom_autologin.conf")
	c.Check(err, C.Equals, nil)
	c.Check(name, C.Equals, "wen")
	name, err = getGDMAutoLoginUser("testdata/autologin/custom.conf")
	c.Check(err, C.Equals, nil)
	c.Check(name, C.Equals, "")
	_, err = getGDMAutoLoginUser("testdata/autologin/xxxx.conf")
	c.Check(err, C.Not(C.Equals), nil)

	name, err = getKDMAutoLoginUser("testdata/autologin/kdmrc_autologin")
	c.Check(err, C.Equals, nil)
	c.Check(name, C.Equals, "wen")
	name, err = getKDMAutoLoginUser("testdata/autologin/kdmrc")
	c.Check(err, C.Equals, nil)
	c.Check(name, C.Equals, "")
	_, err = getKDMAutoLoginUser("testdata/autologin/xxxxx")
	c.Check(err, C.Not(C.Equals), nil)

	m, err := getDefaultDisplayManager("testdata/autologin/default-display-manager")
	c.Check(err, C.Equals, nil)
	c.Check(m, C.Equals, "lightdm")
	_, err = getDefaultDisplayManager("testdata/autologin/xxxxx")
	c.Check(err, C.Not(C.Equals), nil)
}
Beispiel #3
0
func (s *UserSuite) TestPasswordValidUpdatesSalt(c *gc.C) {
	user := s.factory.MakeAnyUser()

	compatHash := utils.UserPasswordHash("foo", utils.CompatSalt)
	err := user.SetPasswordHash(compatHash, "")
	c.Assert(err, gc.IsNil)
	beforeSalt, beforeHash := state.GetUserPasswordSaltAndHash(user)
	c.Assert(beforeSalt, gc.Equals, "")
	c.Assert(beforeHash, gc.Equals, compatHash)
	c.Assert(user.PasswordValid("bar"), jc.IsFalse)
	// A bad password doesn't trigger a rewrite
	afterBadSalt, afterBadHash := state.GetUserPasswordSaltAndHash(user)
	c.Assert(afterBadSalt, gc.Equals, "")
	c.Assert(afterBadHash, gc.Equals, compatHash)
	// When we get a valid check, we then add a salt and rewrite the hash
	c.Assert(user.PasswordValid("foo"), jc.IsTrue)
	afterSalt, afterHash := state.GetUserPasswordSaltAndHash(user)
	c.Assert(afterSalt, gc.Not(gc.Equals), "")
	c.Assert(afterHash, gc.Not(gc.Equals), compatHash)
	c.Assert(afterHash, gc.Equals, utils.UserPasswordHash("foo", afterSalt))
	// running PasswordValid again doesn't trigger another rewrite
	c.Assert(user.PasswordValid("foo"), jc.IsTrue)
	lastSalt, lastHash := state.GetUserPasswordSaltAndHash(user)
	c.Assert(lastSalt, gc.Equals, afterSalt)
	c.Assert(lastHash, gc.Equals, afterHash)
}
Beispiel #4
0
func (s *ConstraintsSuite) TestIsEmpty(c *gc.C) {
	con := constraints.Value{}
	c.Check(&con, jc.Satisfies, constraints.IsEmpty)
	con = constraints.MustParse("arch=amd64")
	c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
	con = constraints.MustParse("")
	c.Check(&con, jc.Satisfies, constraints.IsEmpty)
	con = constraints.MustParse("tags=")
	c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
	con = constraints.MustParse("networks=")
	c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
	con = constraints.MustParse("mem=")
	c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
	con = constraints.MustParse("arch=")
	c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
	con = constraints.MustParse("root-disk=")
	c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
	con = constraints.MustParse("cpu-power=")
	c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
	con = constraints.MustParse("cpu-cores=")
	c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
	con = constraints.MustParse("container=")
	c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
	con = constraints.MustParse("instance-type=")
	c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
}
Beispiel #5
0
func (*metadataHelperSuite) TestResolveMetadata(c *gc.C) {
	var versionStrings = []string{"1.2.3-precise-amd64"}
	dir := c.MkDir()
	ttesting.MakeTools(c, dir, "releases", versionStrings)
	toolsList := coretools.List{{
		Version: version.MustParseBinary(versionStrings[0]),
		Size:    123,
		SHA256:  "abc",
	}}

	stor, err := filestorage.NewFileStorageReader(dir)
	c.Assert(err, gc.IsNil)
	err = tools.ResolveMetadata(stor, nil)
	c.Assert(err, gc.IsNil)

	// We already have size/sha256, so ensure that storage isn't consulted.
	countingStorage := &countingStorage{StorageReader: stor}
	metadata := tools.MetadataFromTools(toolsList)
	err = tools.ResolveMetadata(countingStorage, metadata)
	c.Assert(err, gc.IsNil)
	c.Assert(countingStorage.counter, gc.Equals, 0)

	// Now clear size/sha256, and check that it is called, and
	// the size/sha256 sum are updated.
	metadata[0].Size = 0
	metadata[0].SHA256 = ""
	err = tools.ResolveMetadata(countingStorage, metadata)
	c.Assert(err, gc.IsNil)
	c.Assert(countingStorage.counter, gc.Equals, 1)
	c.Assert(metadata[0].Size, gc.Not(gc.Equals), 0)
	c.Assert(metadata[0].SHA256, gc.Not(gc.Equals), "")
}
Beispiel #6
0
func (s *S) TestNewContainer(c *gocheck.C) {
	oldClusterNodes := clusterNodes
	clusterNodes = map[string]string{"server": s.server.URL()}
	defer func() { clusterNodes = oldClusterNodes }()
	app := testing.NewFakeApp("app-name", "brainfuck", 1)
	rtesting.FakeRouter.AddBackend(app.GetName())
	defer rtesting.FakeRouter.RemoveBackend(app.GetName())
	dockerCluster().PullImage(
		docker.PullImageOptions{Repository: "tsuru/brainfuck"},
		docker.AuthConfiguration{},
	)
	cont, err := newContainer(app, getImage(app), []string{"docker", "run"})
	c.Assert(err, gocheck.IsNil)
	defer s.removeTestContainer(&cont)
	c.Assert(cont.ID, gocheck.Not(gocheck.Equals), "")
	c.Assert(cont, gocheck.FitsTypeOf, container{})
	c.Assert(cont.AppName, gocheck.Equals, app.GetName())
	c.Assert(cont.Type, gocheck.Equals, app.GetPlatform())
	c.Assert(cont.Name, gocheck.Not(gocheck.Equals), "")
	c.Assert(cont.Name, gocheck.HasLen, 20)
	u, _ := url.Parse(s.server.URL())
	host, _, _ := net.SplitHostPort(u.Host)
	c.Assert(cont.HostAddr, gocheck.Equals, host)
	user, err := config.GetString("docker:ssh:user")
	c.Assert(err, gocheck.IsNil)
	dcli, _ := docker.NewClient(s.server.URL())
	container, err := dcli.InspectContainer(cont.ID)
	c.Assert(err, gocheck.IsNil)
	c.Assert(container.Config.User, gocheck.Equals, user)
}
Beispiel #7
0
func (s *S) TestCreateLoadBalancer(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, CreateLoadBalancer)
	createLB := &elb.CreateLoadBalancer{
		Name:       "testlb",
		AvailZones: []string{"us-east-1a", "us-east-1b"},
		Listeners: []elb.Listener{
			{
				InstancePort:     80,
				InstanceProtocol: "http",
				Protocol:         "http",
				LoadBalancerPort: 80,
			},
		},
	}
	resp, err := s.elb.CreateLoadBalancer(createLB)
	c.Assert(err, gocheck.IsNil)
	defer s.elb.DeleteLoadBalancer(createLB.Name)
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Action"), gocheck.Equals, "CreateLoadBalancer")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("LoadBalancerName"), gocheck.Equals, "testlb")
	c.Assert(values.Get("AvailabilityZones.member.1"), gocheck.Equals, "us-east-1a")
	c.Assert(values.Get("AvailabilityZones.member.2"), gocheck.Equals, "us-east-1b")
	c.Assert(values.Get("Listeners.member.1.InstancePort"), gocheck.Equals, "80")
	c.Assert(values.Get("Listeners.member.1.InstanceProtocol"), gocheck.Equals, "http")
	c.Assert(values.Get("Listeners.member.1.Protocol"), gocheck.Equals, "http")
	c.Assert(values.Get("Listeners.member.1.LoadBalancerPort"), gocheck.Equals, "80")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(resp.DNSName, gocheck.Equals, "testlb-339187009.us-east-1.elb.amazonaws.com")
}
Beispiel #8
0
func (s *S) TestConfigureHealthCheck(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, ConfigureHealthCheck)
	hc := elb.HealthCheck{
		HealthyThreshold:   10,
		Interval:           30,
		Target:             "HTTP:80/",
		Timeout:            5,
		UnhealthyThreshold: 2,
	}
	resp, err := s.elb.ConfigureHealthCheck("testlb", &hc)
	c.Assert(err, gocheck.IsNil)
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Action"), gocheck.Equals, "ConfigureHealthCheck")
	c.Assert(values.Get("LoadBalancerName"), gocheck.Equals, "testlb")
	c.Assert(values.Get("HealthCheck.HealthyThreshold"), gocheck.Equals, "10")
	c.Assert(values.Get("HealthCheck.Interval"), gocheck.Equals, "30")
	c.Assert(values.Get("HealthCheck.Target"), gocheck.Equals, "HTTP:80/")
	c.Assert(values.Get("HealthCheck.Timeout"), gocheck.Equals, "5")
	c.Assert(values.Get("HealthCheck.UnhealthyThreshold"), gocheck.Equals, "2")
	c.Assert(resp.HealthCheck.HealthyThreshold, gocheck.Equals, 10)
	c.Assert(resp.HealthCheck.Interval, gocheck.Equals, 30)
	c.Assert(resp.HealthCheck.Target, gocheck.Equals, "HTTP:80/")
	c.Assert(resp.HealthCheck.Timeout, gocheck.Equals, 5)
	c.Assert(resp.HealthCheck.UnhealthyThreshold, gocheck.Equals, 2)
}
Beispiel #9
0
func (s *ConstraintsSuite) TestParseNoTagsNoNetworks(c *gc.C) {
	con := constraints.MustParse("arch=amd64 mem=4G cpu-cores=1 root-disk=8G tags= networks=")
	c.Assert(con.Tags, gc.Not(gc.IsNil))
	c.Assert(con.Networks, gc.Not(gc.IsNil))
	c.Check(*con.Tags, gc.HasLen, 0)
	c.Check(*con.Networks, gc.HasLen, 0)
}
Beispiel #10
0
func (s *S) TestExportEnvironmentsForward(c *gocheck.C) {
	expectedHost := "localhost"
	config.Set("host", expectedHost)
	app := App{Name: "mist", Platform: "opeth"}
	err := s.conn.Apps().Insert(app)
	c.Assert(err, gocheck.IsNil)
	defer s.conn.Apps().Remove(bson.M{"name": app.Name})
	ctx := action.FWContext{Params: []interface{}{&app}}
	result, err := exportEnvironmentsAction.Forward(ctx)
	c.Assert(err, gocheck.IsNil)
	c.Assert(result, gocheck.Equals, nil)
	gotApp, err := GetByName(app.Name)
	c.Assert(err, gocheck.IsNil)
	appEnv := gotApp.InstanceEnv("")
	c.Assert(appEnv["TSURU_APPNAME"].Value, gocheck.Equals, app.Name)
	c.Assert(appEnv["TSURU_APPNAME"].Public, gocheck.Equals, false)
	c.Assert(appEnv["TSURU_HOST"].Value, gocheck.Equals, expectedHost)
	c.Assert(appEnv["TSURU_HOST"].Public, gocheck.Equals, false)
	c.Assert(appEnv["TSURU_APP_TOKEN"].Value, gocheck.Not(gocheck.Equals), "")
	c.Assert(appEnv["TSURU_APP_TOKEN"].Public, gocheck.Equals, false)
	c.Assert(appEnv["TSURU_APPDir"].Value, gocheck.Not(gocheck.Equals), "/home/application/current")
	c.Assert(appEnv["TSURU_APPDir"].Public, gocheck.Equals, false)
	t, err := nativeScheme.Auth(appEnv["TSURU_APP_TOKEN"].Value)
	c.Assert(err, gocheck.IsNil)
	c.Assert(t.IsAppToken(), gocheck.Equals, true)
	c.Assert(t.GetAppName(), gocheck.Equals, app.Name)
}
Beispiel #11
0
func (t *TestWrapper) TestGetLocale(c *C.C) {
	l, err := getLocaleFromFile("testdata/pam_environment")
	c.Check(err, C.Not(C.NotNil))
	c.Check(l, C.Equals, "zh_CN.UTF-8")

	l = getLocale()
	c.Check(len(l), C.Not(C.Equals), 0)
}
Beispiel #12
0
func (*testWrapper) TestSystemMemory(c *C.C) {
	mem, err := getMemoryCapFromFile("/proc/meminfo")
	c.Check(err, C.Not(C.NotNil))
	c.Check(mem, C.Not(C.Equals), uint64(0))
	mem, err = getMemoryCapFromFile("xxxxxxxxx")
	c.Check(err, C.NotNil)
	c.Check(mem, C.Equals, uint64(0))
}
Beispiel #13
0
func (s *UserSuite) TestAddUserSetsSalt(c *gc.C) {
	user := s.factory.MakeUser(factory.UserParams{Password: "******"})
	salt, hash := state.GetUserPasswordSaltAndHash(user)
	c.Check(hash, gc.Not(gc.Equals), "")
	c.Check(salt, gc.Not(gc.Equals), "")
	c.Check(utils.UserPasswordHash("a-password", salt), gc.Equals, hash)
	c.Check(user.PasswordValid("a-password"), jc.IsTrue)
}
Beispiel #14
0
func (*testWrapper) TestSystemCPU(c *C.C) {
	cpu, err := getCPUInfoFromFile("/proc/cpuinfo")
	c.Check(err, C.Not(C.NotNil))
	c.Check(len(cpu), C.Not(C.Equals), 0)
	cpu, err = getCPUInfoFromFile("xxxxxxxxxxx")
	c.Check(err, C.NotNil)
	c.Check(cpu, C.Equals, "")
}
Beispiel #15
0
func (*testWrapper) TestLayoutList(c *C.C) {
	v, err := getLayoutListByFile("testdata/base.xml")
	c.Check(err, C.Not(C.NotNil))
	c.Check(v, C.NotNil)

	v, err = getLayoutListByFile("testdata/xxxxxx.xml")
	c.Check(err, C.NotNil)
	c.Check(v, C.Not(C.NotNil))
}
Beispiel #16
0
func (s *NewAPIClientSuite) TestWithConfigAndNoInfo(c *gc.C) {
	coretesting.MakeSampleJujuHome(c)

	store := newConfigStore(coretesting.SampleEnvName, &environInfo{
		bootstrapConfig: map[string]interface{}{
			"type":                      "dummy",
			"name":                      "myenv",
			"state-server":              true,
			"authorized-keys":           "i-am-a-key",
			"default-series":            config.LatestLtsSeries(),
			"firewall-mode":             config.FwInstance,
			"development":               false,
			"ssl-hostname-verification": true,
			"admin-secret":              "adminpass",
		},
	})
	bootstrapEnv(c, coretesting.SampleEnvName, store)

	// Verify the cache is empty.
	info, err := store.ReadInfo("myenv")
	c.Assert(err, gc.IsNil)
	c.Assert(info, gc.NotNil)
	c.Assert(info.APIEndpoint(), jc.DeepEquals, configstore.APIEndpoint{})
	c.Assert(info.APICredentials(), jc.DeepEquals, configstore.APICredentials{})

	called := 0
	expectState := mockedAPIState(0)
	apiOpen := func(apiInfo *api.Info, opts api.DialOpts) (juju.APIState, error) {
		c.Check(apiInfo.Tag, gc.Equals, names.NewUserTag("admin"))
		c.Check(string(apiInfo.CACert), gc.Not(gc.Equals), "")
		c.Check(apiInfo.Password, gc.Equals, "adminpass")
		// EnvironTag wasn't in regular Config
		c.Check(apiInfo.EnvironTag, gc.IsNil)
		c.Check(opts, gc.DeepEquals, api.DefaultDialOpts())
		called++
		return expectState, nil
	}
	st, err := juju.NewAPIFromStore("myenv", store, apiOpen)
	c.Assert(err, gc.IsNil)
	c.Assert(st, gc.Equals, expectState)
	c.Assert(called, gc.Equals, 1)

	// Make sure the cache is updated.
	info, err = store.ReadInfo("myenv")
	c.Assert(err, gc.IsNil)
	c.Assert(info, gc.NotNil)
	ep := info.APIEndpoint()
	c.Assert(ep.Addresses, gc.HasLen, 1)
	c.Check(ep.Addresses[0], gc.Matches, `localhost:\d+`)
	c.Check(ep.CACert, gc.Not(gc.Equals), "")
	// Old servers won't hand back EnvironTag, so it should stay empty in
	// the cache
	c.Check(ep.EnvironUUID, gc.Equals, "")
	creds := info.APICredentials()
	c.Check(creds.User, gc.Equals, "admin")
	c.Check(creds.Password, gc.Equals, "adminpass")
}
Beispiel #17
0
func (*testWrapper) TestGetLangList(c *C.C) {
	langList, err := GetLanguageInfoList("testdata/xxx.json")
	c.Check(err, C.NotNil)
	c.Check(len(langList), C.Equals, 0)

	langList, err = GetLanguageInfoList("testdata/support_languages.json")
	c.Check(err, C.Not(C.NotNil))
	c.Check(len(langList), C.Not(C.Equals), 0)
}
Beispiel #18
0
func (t *TestWrapper) TestLocaleInfoList(c *C.C) {
	list, err := getLocaleInfoList("testdata/support_languages.json")
	c.Check(len(list), C.Not(C.Equals), 0)
	c.Check(err, C.Not(C.NotNil))

	list, err = getLocaleInfoList("testdata/zzxxxxxxx")
	c.Check(len(list), C.Equals, 0)
	c.Check(err, C.NotNil)
}
Beispiel #19
0
func (s *UserSuite) TestAddUserSetsSalt(c *gc.C) {
	u, err := s.State.AddUser("someuser", "a-password")
	c.Assert(err, gc.IsNil)
	salt, hash := state.GetUserPasswordSaltAndHash(u)
	c.Check(hash, gc.Not(gc.Equals), "")
	c.Check(salt, gc.Not(gc.Equals), "")
	c.Check(utils.UserPasswordHash("a-password", salt), gc.Equals, hash)
	c.Check(u.PasswordValid("a-password"), jc.IsTrue)
}
Beispiel #20
0
func (s *S) TestScan(c *check.C) {
	n := int(1e4)
	tree := testTree(n, 1e3, 1e2, 1e5)

	root := tree[""]

	ss := fillSliceWith(tree.Traverse(""), n)

	leftMost := root.LeftMost()
	c.Check(leftMost, check.Equals, ss[0])
	c.Check(leftMost.ScanLeft(), check.IsNil)

	rightMost := root.RightMost()
	c.Check(rightMost, check.Equals, ss[len(ss)-1])
	c.Check(rightMost.ScanRight(), check.IsNil)

	var (
		last  *Interval
		count int
	)
	for seg := leftMost; seg != nil && count <= n+1; seg, count = seg.ScanRight(), count+1 {
		if last != nil {
			c.Check(seg.start, check.Not(lessThan), last.start)
		}
	}
	c.Check(count, check.Equals, n)

	last, count = nil, 0
	for seg := rightMost; seg != nil && count <= n+1; seg, count = seg.ScanLeft(), count+1 {
		if last != nil {
			c.Check(last.start, check.Not(lessThan), seg.start)
		}
	}
	c.Check(count, check.Equals, n)

	desc := "((a,c)b,(e,g)f)d;"
	mock := makeTree(desc)
	c.Check(mock.LeftMost().ScanLeft(), check.IsNil)
	c.Check(mock.RightMost().ScanRight(), check.IsNil)
	c.Check(string(mock.LeftMost().line), check.Equals, "a")

	for label, node := 'a', mock.LeftMost(); label <= 'g'; label, node = label+1, node.ScanRight() {
		c.Check(string(node.line), check.Equals, string(label))
	}

	for i := range ss {
		if i > 0 {
			c.Check(ss[i].ScanLeft(), check.DeepEquals, ss[i-1])
			c.Check(ss[i].ScanLeft().ScanRight(), check.DeepEquals, ss[i])
		}
		if i < len(ss)-1 {
			c.Check(ss[i].ScanRight(), check.DeepEquals, ss[i+1])
			c.Check(ss[i].ScanRight().ScanLeft(), check.DeepEquals, ss[i])
		}
	}
}
Beispiel #21
0
func (s *S) TestDescribeLoadBalancersByName(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, DescribeLoadBalancers)
	s.elb.DescribeLoadBalancers("somelb")
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Action"), gocheck.Equals, "DescribeLoadBalancers")
	c.Assert(values.Get("LoadBalancerNames.member.1"), gocheck.Equals, "somelb")
}
Beispiel #22
0
func (*testingSuite) TestPatchAttemptStrategiesPatchesEnvironsStrategies(c *gc.C) {
	c.Assert(environs.LongAttempt, gc.Not(gc.DeepEquals), impatientAttempt)
	c.Assert(environs.ShortAttempt, gc.Not(gc.DeepEquals), impatientAttempt)

	cleanup := PatchAttemptStrategies()
	defer cleanup()

	c.Check(environs.LongAttempt, gc.DeepEquals, impatientAttempt)
	c.Check(environs.ShortAttempt, gc.DeepEquals, impatientAttempt)
}
Beispiel #23
0
func (s *RelopSuite) TestGreaterThan(c *gc.C) {
	c.Assert(45, jc.GreaterThan, 42)
	c.Assert(2.25, jc.GreaterThan, 1.0)
	c.Assert(42, gc.Not(jc.GreaterThan), 42)
	c.Assert(10, gc.Not(jc.GreaterThan), 42)

	result, msg := jc.GreaterThan.Check([]interface{}{"Hello", "World"}, nil)
	c.Assert(result, jc.IsFalse)
	c.Assert(msg, gc.Equals, `obtained value string:"Hello" not supported`)
}
Beispiel #24
0
func (s *RelopSuite) TestLessThan(c *gc.C) {
	c.Assert(42, jc.LessThan, 45)
	c.Assert(1.0, jc.LessThan, 2.25)
	c.Assert(42, gc.Not(jc.LessThan), 42)
	c.Assert(42, gc.Not(jc.LessThan), 10)

	result, msg := jc.LessThan.Check([]interface{}{"Hello", "World"}, nil)
	c.Assert(result, jc.IsFalse)
	c.Assert(msg, gc.Equals, `obtained value string:"Hello" not supported`)
}
Beispiel #25
0
func (s *managedStorageSuite) TestPutSamePathDifferentDataMulti(c *gc.C) {
	resPath := s.assertPut(c, "/path/to/blob", []byte("another resource"))
	secondResPath := s.assertPut(c, "/anotherpath/to/blob", []byte("some resource"))
	c.Assert(resPath, gc.Not(gc.Equals), secondResPath)
	s.assertResourceCatalogCount(c, 2)

	thirdResPath := s.assertPut(c, "/path/to/blob", []byte("some resource"))
	c.Assert(resPath, gc.Not(gc.Equals), secondResPath)
	c.Assert(secondResPath, gc.Equals, thirdResPath)
	s.assertResourceCatalogCount(c, 1)
}
Beispiel #26
0
func (s *UserSuite) TestSetPasswordChangesSalt(c *gc.C) {
	user := s.factory.MakeUser(c, nil)
	origSalt, origHash := state.GetUserPasswordSaltAndHash(user)
	c.Assert(origSalt, gc.Not(gc.Equals), "")
	user.SetPassword("a-password")
	newSalt, newHash := state.GetUserPasswordSaltAndHash(user)
	c.Assert(newSalt, gc.Not(gc.Equals), "")
	c.Assert(newSalt, gc.Not(gc.Equals), origSalt)
	c.Assert(newHash, gc.Not(gc.Equals), origHash)
	c.Assert(user.PasswordValid("a-password"), jc.IsTrue)
}
Beispiel #27
0
func (*testWrapper) TestSystemVersion(c *C.C) {
	version, err := getVersionFromDeepin("/etc/deepin-version")
	c.Check(err, C.Not(C.NotNil))
	c.Check(len(version), C.Not(C.Equals), 0)
	version, err = getVersionFromLsb("/etc/lsb-release")
	c.Check(err, C.Not(C.NotNil))
	c.Check(len(version), C.Not(C.Equals), 0)
	version, err = getVersionFromDeepin("xxxxxxxxxx")
	c.Check(err, C.NotNil)
	c.Check(len(version), C.Equals, 0)
}
Beispiel #28
0
func (s *S) TestRangeCheck(c *check.C) {
	var err error
	_, err = NewGeneric(string([]rune{256}), 0, 0, 0, !CaseSensitive)
	c.Check(err, check.Not(check.IsNil))
	_, err = NewGeneric(string([]rune{0}), 0, 0, 0, !CaseSensitive)
	c.Check(err, check.IsNil)
	_, err = NewGeneric(string([]rune{127}), 0, 0, 0, !CaseSensitive)
	c.Check(err, check.IsNil)
	_, err = NewGeneric(string([]rune{-1}), 0, 0, 0, !CaseSensitive)
	c.Check(err, check.Not(check.IsNil))
}
Beispiel #29
0
func (s *S) TestContainerNetworkInfo(c *gocheck.C) {
	err := newImage("tsuru/python", s.server.URL())
	c.Assert(err, gocheck.IsNil)
	cont, err := s.newContainer(nil)
	c.Assert(err, gocheck.IsNil)
	defer s.removeTestContainer(cont)
	info, err := cont.networkInfo()
	c.Assert(err, gocheck.IsNil)
	c.Assert(info.IP, gocheck.Not(gocheck.Equals), "")
	c.Assert(info.HTTPHostPort, gocheck.Not(gocheck.Equals), "")
	c.Assert(info.SSHHostPort, gocheck.Not(gocheck.Equals), "")
}
Beispiel #30
0
func (s *S) TestDeleteLoadBalancer(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, DeleteLoadBalancer)
	resp, err := s.elb.DeleteLoadBalancer("testlb")
	c.Assert(err, gocheck.IsNil)
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Action"), gocheck.Equals, "DeleteLoadBalancer")
	c.Assert(values.Get("LoadBalancerName"), gocheck.Equals, "testlb")
	c.Assert(resp.RequestId, gocheck.Equals, "8d7223db-49d7-11e2-bba9-35ba56032fe1")
}