本文整理汇总了Golang中github.com/tsuru/tsuru/auth.ManagedScheme函数的典型用法代码示例。如果您正苦于以下问题:Golang ManagedScheme函数的具体用法?Golang ManagedScheme怎么用?Golang ManagedScheme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ManagedScheme函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestListDeployByNonAdminUsers
func (s *S) TestListDeployByNonAdminUsers(c *check.C) {
user := &auth.User{Email: "[email protected]", Password: "123456"}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
AuthScheme = nativeScheme
_, err := nativeScheme.Create(user)
c.Assert(err, check.IsNil)
defer nativeScheme.Remove(user)
team := &auth.Team{Name: "someteam", Users: []string{user.Email}}
err = s.conn.Teams().Insert(team)
c.Assert(err, check.IsNil)
defer s.conn.Teams().RemoveId("someteam")
s.conn.Deploys().RemoveAll(nil)
a := App{Name: "g1", Teams: []string{team.Name}}
err = s.conn.Apps().Insert(a)
c.Assert(err, check.IsNil)
a2 := App{Name: "ge"}
err = s.conn.Apps().Insert(a2)
c.Assert(err, check.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
defer s.conn.Apps().Remove(bson.M{"name": a2.Name})
deploys := []DeployData{
{App: "g1", Timestamp: time.Now().Add(-3600 * time.Second)},
{App: "ge", Timestamp: time.Now()},
}
for _, deploy := range deploys {
s.conn.Deploys().Insert(deploy)
}
defer s.conn.Deploys().RemoveAll(bson.M{"app": a.Name})
result, err := ListDeploys(nil, nil, user, 0, 0)
c.Assert(err, check.IsNil)
c.Assert(result, check.HasLen, 1)
c.Assert(result[0].App, check.Equals, "g1")
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:33,代码来源:deploy_test.go
示例2: SetUpTest
func (s *S) SetUpTest(c *check.C) {
queue.ResetQueue()
err := rebuild.RegisterTask(func(appName string) (rebuild.RebuildApp, error) {
a, err := app.GetByName(appName)
if err == app.ErrAppNotFound {
return nil, nil
}
return a, err
})
c.Assert(err, check.IsNil)
routertest.FakeRouter.Reset()
provisiontest.ProvisionerInstance.Reset()
err = dbtest.ClearAllCollections(s.conn.Apps().Database)
c.Assert(err, check.IsNil)
s.user = &auth.User{Email: "[email protected]", Password: "123456", Quota: quota.Unlimited}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
app.AuthScheme = nativeScheme
_, err = nativeScheme.Create(s.user)
c.Assert(err, check.IsNil)
s.team = &auth.Team{Name: "admin"}
c.Assert(err, check.IsNil)
err = s.conn.Teams().Insert(s.team)
c.Assert(err, check.IsNil)
err = provision.AddPool(provision.AddPoolOptions{
Name: "p1",
Default: true,
Provisioner: "fake",
})
c.Assert(err, check.IsNil)
}
开发者ID:tsuru,项目名称:tsuru,代码行数:30,代码来源:suite_test.go
示例3: TestGetDeploy
func (s *S) TestGetDeploy(c *check.C) {
user := &auth.User{Email: "[email protected]", Password: "123456"}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
AuthScheme = nativeScheme
_, err := nativeScheme.Create(user)
c.Assert(err, check.IsNil)
defer user.Delete()
team := &auth.Team{Name: "team", Users: []string{user.Email}}
err = s.conn.Teams().Insert(team)
c.Assert(err, check.IsNil)
defer s.conn.Teams().Remove(team)
a := App{
Name: "g1",
Platform: "zend",
Teams: []string{team.Name},
}
err = s.conn.Apps().Insert(a)
c.Assert(err, check.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
s.conn.Deploys().RemoveAll(nil)
newDeploy := DeployData{ID: bson.NewObjectId(), App: "g1", Timestamp: time.Now()}
err = s.conn.Deploys().Insert(&newDeploy)
c.Assert(err, check.IsNil)
defer s.conn.Deploys().Remove(bson.M{"name": newDeploy.App})
lastDeploy, err := GetDeploy(newDeploy.ID.Hex(), user)
c.Assert(err, check.IsNil)
ts := lastDeploy.Timestamp
lastDeploy.Timestamp = time.Date(ts.Year(), ts.Month(), ts.Day(), ts.Hour(), ts.Minute(), ts.Second(), 0, time.UTC)
ts = newDeploy.Timestamp
newDeploy.Timestamp = time.Date(ts.Year(), ts.Month(), ts.Day(), ts.Hour(), ts.Minute(), ts.Second(), 0, time.UTC)
c.Assert(lastDeploy.ID, check.Equals, newDeploy.ID)
c.Assert(lastDeploy.App, check.Equals, newDeploy.App)
c.Assert(lastDeploy.Timestamp, check.Equals, newDeploy.Timestamp)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:34,代码来源:deploy_test.go
示例4: SetUpTest
func (s *S) SetUpTest(c *check.C) {
routertest.FakeRouter.Reset()
rand.Seed(0)
config.Set("swarm:swarm-port", 0)
err := dbtest.ClearAllCollections(s.conn.Apps().Database)
c.Assert(err, check.IsNil)
err = provision.AddPool(provision.AddPoolOptions{Name: "bonehunters", Default: true, Provisioner: "swarm"})
c.Assert(err, check.IsNil)
p := app.Plan{
Name: "default",
Router: "fake",
Default: true,
CpuShare: 100,
}
err = p.Save()
c.Assert(err, check.IsNil)
s.p = &swarmProvisioner{}
err = s.p.Initialize()
c.Assert(err, check.IsNil)
s.user = &auth.User{Email: "[email protected]", Password: "123456", Quota: quota.Unlimited}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
app.AuthScheme = nativeScheme
_, err = nativeScheme.Create(s.user)
c.Assert(err, check.IsNil)
s.team = &auth.Team{Name: "admin"}
c.Assert(err, check.IsNil)
err = s.conn.Teams().Insert(s.team)
c.Assert(err, check.IsNil)
s.token, err = nativeScheme.Login(map[string]string{"email": s.user.Email, "password": "123456"})
c.Assert(err, check.IsNil)
}
开发者ID:tsuru,项目名称:tsuru,代码行数:31,代码来源:suite_test.go
示例5: SetUpTest
func (s *S) SetUpTest(c *check.C) {
config.Set("database:url", "127.0.0.1:27017")
config.Set("database:name", "tsuru_events_migrate_tests")
conn, err := db.Conn()
c.Assert(err, check.IsNil)
defer conn.Close()
err = dbtest.ClearAllCollections(conn.Events().Database)
c.Assert(err, check.IsNil)
config.Set("routers:fake:type", "fake")
err = (&app.Plan{Name: "default", Router: "fake", CpuShare: 100, Default: true}).Save()
c.Assert(err, check.IsNil)
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
app.AuthScheme = nativeScheme
s.user = &auth.User{Email: "[email protected]", Password: "123456"}
_, err = nativeScheme.Create(s.user)
c.Assert(err, check.IsNil)
s.team = &auth.Team{Name: "angra"}
err = conn.Teams().Insert(s.team)
c.Assert(err, check.IsNil)
provision.DefaultProvisioner = "fake"
provisiontest.ProvisionerInstance.Reset()
opts := provision.AddPoolOptions{Name: "test1", Default: true}
err = provision.AddPool(opts)
c.Assert(err, check.IsNil)
}
开发者ID:tsuru,项目名称:tsuru,代码行数:25,代码来源:migrate_test.go
示例6: SetUpSuite
func (s *S) SetUpSuite(c *check.C) {
config.Set("database:url", "127.0.0.1:27017?maxPoolSize=100")
config.Set("database:name", "docker_provision_bs_tests")
config.Set("docker:cluster:mongo-url", "127.0.0.1:27017")
config.Set("docker:cluster:mongo-database", "docker_provision_bs_tests_cluster_stor")
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
app.AuthScheme = nativeScheme
conn, err := db.Conn()
c.Assert(err, check.IsNil)
defer conn.Close()
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:11,代码来源:suite_test.go
示例7: createUserAndTeam
func (s *DeploySuite) createUserAndTeam(c *check.C) {
user := &auth.User{Email: "[email protected]", Password: "123456"}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
app.AuthScheme = nativeScheme
_, err := nativeScheme.Create(user)
c.Assert(err, check.IsNil)
s.team = &auth.Team{Name: "tsuruteam", Users: []string{user.Email}}
err = s.conn.Teams().Insert(s.team)
c.Assert(err, check.IsNil)
s.token, err = nativeScheme.Login(map[string]string{"email": user.Email, "password": "123456"})
c.Assert(err, check.IsNil)
}
开发者ID:keymon,项目名称:tsuru,代码行数:12,代码来源:deploy_test.go
示例8: SetUpSuite
func (s *S) SetUpSuite(c *check.C) {
config.Set("database:url", "127.0.0.1:27017?maxPoolSize=100")
config.Set("database:name", "docker_provision_healer_tests")
config.Set("docker:repository-namespace", "tsuru")
config.Set("docker:cluster:mongo-url", "127.0.0.1:27017")
config.Set("docker:cluster:mongo-database", "docker_provision_healer_tests_cluster_stor")
config.Set("queue:mongo-url", "127.0.0.1:27017")
config.Set("queue:mongo-database", "queue_provision_docker_tests_healer")
config.Set("queue:mongo-polling-interval", 0.01)
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
app.AuthScheme = nativeScheme
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:12,代码来源:suite_test.go
示例9: SetUpSuite
func (s *S) SetUpSuite(c *check.C) {
s.collName = "docker_unit"
s.imageCollName = "docker_image"
s.repoNamespace = "tsuru"
s.sshUser = "root"
s.port = "8888"
config.Set("database:url", "127.0.0.1:27017?maxPoolSize=100")
config.Set("database:name", "docker_provision_tests_s")
config.Set("docker:repository-namespace", s.repoNamespace)
config.Set("docker:router", "fake")
config.Set("docker:collection", s.collName)
config.Set("docker:deploy-cmd", "/var/lib/tsuru/deploy")
config.Set("docker:run-cmd:bin", "/usr/local/bin/circusd /etc/circus/circus.ini")
config.Set("docker:run-cmd:port", s.port)
config.Set("docker:user", s.sshUser)
config.Set("docker:cluster:mongo-url", "127.0.0.1:27017")
config.Set("docker:cluster:mongo-database", "docker_provision_tests_cluster_stor")
config.Set("queue:mongo-url", "127.0.0.1:27017")
config.Set("queue:mongo-database", "queue_provision_docker_tests")
config.Set("queue:mongo-polling-interval", 0.01)
config.Set("routers:fake:type", "fake")
config.Set("repo-manager", "fake")
config.Set("admin-team", "admin")
config.Set("docker:registry-max-try", 1)
config.Set("auth:hash-cost", bcrypt.MinCost)
s.deployCmd = "/var/lib/tsuru/deploy"
s.runBin = "/usr/local/bin/circusd"
s.runArgs = "/etc/circus/circus.ini"
os.Setenv("TSURU_TARGET", "http://localhost")
s.oldProvisioner = app.Provisioner
var err error
s.storage, err = db.Conn()
c.Assert(err, check.IsNil)
clusterDbUrl, _ := config.GetString("docker:cluster:mongo-url")
s.clusterSess, err = mgo.Dial(clusterDbUrl)
c.Assert(err, check.IsNil)
err = dbtest.ClearAllCollections(s.storage.Apps().Database)
c.Assert(err, check.IsNil)
repositorytest.Reset()
s.user = &auth.User{Email: "[email protected]", Password: "123456", Quota: quota.Unlimited}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
app.AuthScheme = nativeScheme
_, err = nativeScheme.Create(s.user)
c.Assert(err, check.IsNil)
s.team = &auth.Team{Name: "admin", Users: []string{s.user.Email}}
c.Assert(err, check.IsNil)
err = s.storage.Teams().Insert(s.team)
c.Assert(err, check.IsNil)
s.token, err = nativeScheme.Login(map[string]string{"email": s.user.Email, "password": "123456"})
c.Assert(err, check.IsNil)
}
开发者ID:4eek,项目名称:tsuru,代码行数:51,代码来源:suite_test.go
示例10: SetUpTest
func (s *S) SetUpTest(c *check.C) {
config.Set("database:url", "127.0.0.1:27017")
config.Set("database:name", "tsuru_events_list_tests")
config.Set("auth:hash-cost", bcrypt.MinCost)
conn, err := db.Conn()
c.Assert(err, check.IsNil)
defer conn.Close()
err = dbtest.ClearAllCollections(conn.Events().Database)
c.Assert(err, check.IsNil)
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
user := &auth.User{Email: "[email protected]", Password: "123456"}
_, err = nativeScheme.Create(user)
c.Assert(err, check.IsNil)
s.token, err = nativeScheme.Login(map[string]string{"email": user.Email, "password": "123456"})
c.Assert(err, check.IsNil)
}
开发者ID:tsuru,项目名称:tsuru,代码行数:16,代码来源:eventlist_test.go
示例11: TestListAllDeploys
func (s *S) TestListAllDeploys(c *check.C) {
user := &auth.User{Email: "[email protected]", Password: "123456"}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
AuthScheme = nativeScheme
_, err := nativeScheme.Create(user)
c.Assert(err, check.IsNil)
defer user.Delete()
team := &auth.Team{Name: "team", Users: []string{user.Email}}
err = s.conn.Teams().Insert(team)
c.Assert(err, check.IsNil)
defer s.conn.Teams().Remove(team)
a := App{
Name: "g1",
Platform: "zend",
Teams: []string{team.Name},
}
err = s.conn.Apps().Insert(a)
c.Assert(err, check.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
a = App{
Name: "ge",
Platform: "zend",
Teams: []string{team.Name},
}
err = s.conn.Apps().Insert(a)
c.Assert(err, check.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
s.conn.Deploys().RemoveAll(nil)
insert := []interface{}{
DeployData{App: "g1", Timestamp: time.Now().Add(-3600 * time.Second)},
DeployData{App: "ge", Timestamp: time.Now(), Image: "app-image"},
}
s.conn.Deploys().Insert(insert...)
defer s.conn.Deploys().RemoveAll(nil)
expected := []DeployData{insert[1].(DeployData), insert[0].(DeployData)}
expected[0].CanRollback = true
deploys, err := ListDeploys(nil, nil, user, 0, 0)
c.Assert(err, check.IsNil)
for i := 0; i < 2; i++ {
ts := expected[i].Timestamp
expected[i].Timestamp = time.Date(ts.Year(), ts.Month(), ts.Day(), ts.Hour(), ts.Minute(), ts.Second(), 0, time.UTC)
ts = deploys[i].Timestamp
deploys[i].Timestamp = time.Date(ts.Year(), ts.Month(), ts.Day(), ts.Hour(), ts.Minute(), ts.Second(), 0, time.UTC)
expected[i].ID = deploys[i].ID
}
c.Assert(deploys, check.DeepEquals, expected)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:47,代码来源:deploy_test.go
示例12: TestListAllDeploysSkipAndLimit
func (s *S) TestListAllDeploysSkipAndLimit(c *check.C) {
user := &auth.User{Email: "[email protected]", Password: "123456"}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
AuthScheme = nativeScheme
_, err := nativeScheme.Create(user)
c.Assert(err, check.IsNil)
defer user.Delete()
team := &auth.Team{Name: "team", Users: []string{user.Email}}
err = s.conn.Teams().Insert(team)
c.Assert(err, check.IsNil)
defer s.conn.Teams().Remove(team)
a := App{
Name: "app1",
Platform: "zend",
Teams: []string{team.Name},
}
err = s.conn.Apps().Insert(a)
c.Assert(err, check.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
s.conn.Deploys().RemoveAll(nil)
insert := []interface{}{
DeployData{App: "app1", Commit: "v1", Timestamp: time.Now().Add(-30 * time.Second)},
DeployData{App: "app1", Commit: "v2", Timestamp: time.Now().Add(-20 * time.Second)},
DeployData{App: "app1", Commit: "v3", Timestamp: time.Now().Add(-10 * time.Second)},
DeployData{App: "app1", Commit: "v4", Timestamp: time.Now()},
}
s.conn.Deploys().Insert(insert...)
defer s.conn.Deploys().RemoveAll(nil)
expected := []DeployData{insert[2].(DeployData), insert[1].(DeployData)}
deploys, err := ListDeploys(nil, nil, user, 1, 2)
c.Assert(err, check.IsNil)
c.Assert(deploys, check.HasLen, 2)
for i := 0; i < len(deploys); i++ {
ts := expected[i].Timestamp
newTs := time.Date(ts.Year(), ts.Month(), ts.Day(), ts.Hour(), ts.Minute(), ts.Second(), 0, time.UTC)
expected[i].Timestamp = newTs
ts = deploys[i].Timestamp
deploys[i].Timestamp = newTs
expected[i].ID = deploys[i].ID
}
c.Assert(deploys, check.DeepEquals, expected)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:42,代码来源:deploy_test.go
示例13: TestDeployInfoByNonAdminUser
func (s *DeploySuite) TestDeployInfoByNonAdminUser(c *check.C) {
user, _ := s.token.User()
a := app.App{Name: "g1", Platform: "python", Teams: []string{s.team.Name}}
err := app.CreateApp(&a, user)
c.Assert(err, check.IsNil)
defer app.Delete(&a)
user = &auth.User{Email: "[email protected]", Password: "123456"}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
app.AuthScheme = nativeScheme
_, err = nativeScheme.Create(user)
c.Assert(err, check.IsNil)
defer user.Delete()
team := &auth.Team{Name: "team", Users: []string{user.Email}}
err = s.conn.Teams().Insert(team)
c.Assert(err, check.IsNil)
defer s.conn.Teams().Remove(team)
token, err := nativeScheme.Login(map[string]string{"email": user.Email, "password": "123456"})
c.Assert(err, check.IsNil)
recorder := httptest.NewRecorder()
timestamp := time.Now()
duration := time.Duration(10e9)
previousDeploy := app.DeployData{App: "g1", Timestamp: timestamp.Add(-3600 * time.Second), Duration: duration, Commit: "e293e3e3me03ejm3puejmp3ej3iejop32", Error: ""}
err = s.conn.Deploys().Insert(previousDeploy)
c.Assert(err, check.IsNil)
lastDeploy := app.DeployData{App: "g1", Timestamp: timestamp, Duration: duration, Commit: "e82nn93nd93mm12o2ueh83dhbd3iu112", Error: ""}
err = s.conn.Deploys().Insert(lastDeploy)
c.Assert(err, check.IsNil)
defer s.conn.Deploys().RemoveAll(nil)
var d map[string]interface{}
err = s.conn.Deploys().Find(bson.M{"commit": lastDeploy.Commit}).One(&d)
c.Assert(err, check.IsNil)
lastDeployId := d["_id"].(bson.ObjectId).Hex()
url := fmt.Sprintf("/deploys/%s", lastDeployId)
request, err := http.NewRequest("GET", url, nil)
c.Assert(err, check.IsNil)
request.Header.Set("Authorization", "bearer "+token.GetValue())
server := RunServer(true)
server.ServeHTTP(recorder, request)
c.Assert(recorder.Code, check.Equals, http.StatusNotFound)
body := recorder.Body.String()
c.Assert(body, check.Equals, "Deploy not found.\n")
}
开发者ID:keymon,项目名称:tsuru,代码行数:42,代码来源:deploy_test.go
示例14: TestUserHasNoPermission
func (s *S) TestUserHasNoPermission(c *check.C) {
user := &auth.User{Email: "[email protected]", Password: "123456"}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
AuthScheme = nativeScheme
_, err := nativeScheme.Create(user)
c.Assert(err, check.IsNil)
defer user.Delete()
team := &auth.Team{Name: "team", Users: []string{user.Email}}
err = s.conn.Teams().Insert(team)
c.Assert(err, check.IsNil)
defer s.conn.Teams().Remove(team)
a := App{
Name: "g1",
Platform: "zend",
}
err = s.conn.Apps().Insert(a)
c.Assert(err, check.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
hasPermission := userHasPermission(user, a.Name)
c.Assert(hasPermission, check.Equals, false)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:21,代码来源:deploy_test.go
示例15: TestListDeployByAppAndUser
func (s *S) TestListDeployByAppAndUser(c *check.C) {
user := &auth.User{Email: "[email protected]", Password: "123456"}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
AuthScheme = nativeScheme
_, err := nativeScheme.Create(user)
c.Assert(err, check.IsNil)
defer user.Delete()
team := &auth.Team{Name: "team", Users: []string{user.Email}}
err = s.conn.Teams().Insert(team)
c.Assert(err, check.IsNil)
defer s.conn.Teams().Remove(team)
a := App{
Name: "g1",
Platform: "zend",
Teams: []string{team.Name},
}
err = s.conn.Apps().Insert(a)
c.Assert(err, check.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
a = App{
Name: "ge",
Platform: "zend",
Teams: []string{team.Name},
}
err = s.conn.Apps().Insert(a)
c.Assert(err, check.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
s.conn.Deploys().RemoveAll(nil)
insert := []interface{}{
DeployData{App: "g1", Timestamp: time.Now().Add(-3600 * time.Second)},
DeployData{App: "ge", Timestamp: time.Now()},
}
s.conn.Deploys().Insert(insert...)
defer s.conn.Deploys().RemoveAll(nil)
expected := []DeployData{insert[1].(DeployData)}
deploys, err := ListDeploys(&a, nil, user, 0, 0)
c.Assert(err, check.IsNil)
c.Assert(expected[0].App, check.DeepEquals, deploys[0].App)
c.Assert(len(expected), check.Equals, len(deploys))
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:40,代码来源:deploy_test.go
示例16: SetUpSuite
func (s *HandlersSuite) SetUpSuite(c *check.C) {
config.Set("database:name", "docker_provision_handlers_tests_s")
config.Set("docker:collection", "docker_handler_suite")
config.Set("docker:run-cmd:port", 8888)
config.Set("docker:router", "fake")
config.Set("docker:cluster:mongo-url", "127.0.0.1:27017")
config.Set("docker:cluster:mongo-database", "docker_provision_handlers_tests_cluster_stor")
config.Set("docker:repository-namespace", "tsuru")
config.Set("queue:mongo-url", "127.0.0.1:27017")
config.Set("queue:mongo-database", "queue_provision_docker_tests_handlers")
config.Set("iaas:default", "test-iaas")
config.Set("iaas:node-protocol", "http")
config.Set("iaas:node-port", 1234)
config.Set("admin-team", "admin")
config.Set("routers:fake:type", "fake")
var err error
s.conn, err = db.Conn()
c.Assert(err, check.IsNil)
clusterDbUrl, _ := config.GetString("docker:cluster:mongo-url")
s.clusterSess, err = mgo.Dial(clusterDbUrl)
c.Assert(err, check.IsNil)
pools, err := provision.ListPools(nil)
c.Assert(err, check.IsNil)
for _, pool := range pools {
err = provision.RemovePool(pool.Name)
c.Assert(err, check.IsNil)
}
s.user = &auth.User{Email: "[email protected]", Password: "123456", Quota: quota.Unlimited}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
app.AuthScheme = nativeScheme
_, err = nativeScheme.Create(s.user)
c.Assert(err, check.IsNil)
s.team = &auth.Team{Name: "admin", Users: []string{s.user.Email}}
err = s.conn.Teams().Insert(s.team)
c.Assert(err, check.IsNil)
s.token, err = nativeScheme.Login(map[string]string{"email": s.user.Email, "password": "123456"})
c.Assert(err, check.IsNil)
}
开发者ID:mderaldo,项目名称:tsuru,代码行数:38,代码来源:handlers_test.go
示例17: TestGetDeployWithoutAccess
func (s *S) TestGetDeployWithoutAccess(c *check.C) {
user := &auth.User{Email: "[email protected]", Password: "123456"}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
AuthScheme = nativeScheme
_, err := nativeScheme.Create(user)
c.Assert(err, check.IsNil)
defer user.Delete()
a := App{
Name: "g1",
Platform: "zend",
}
err = s.conn.Apps().Insert(a)
c.Assert(err, check.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
s.conn.Deploys().RemoveAll(nil)
newDeploy := DeployData{ID: bson.NewObjectId(), App: "g1", Timestamp: time.Now()}
err = s.conn.Deploys().Insert(&newDeploy)
c.Assert(err, check.IsNil)
defer s.conn.Deploys().Remove(bson.M{"name": newDeploy.App})
result, err := GetDeploy(newDeploy.ID.Hex(), user)
c.Assert(err.Error(), check.Equals, "Deploy not found.")
c.Assert(result, check.IsNil)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:23,代码来源:deploy_test.go
示例18: TestDeployListNonAdmin
func (s *DeploySuite) TestDeployListNonAdmin(c *check.C) {
user := &auth.User{Email: "[email protected]", Password: "123456"}
nativeScheme := auth.ManagedScheme(native.NativeScheme{})
app.AuthScheme = nativeScheme
_, err := nativeScheme.Create(user)
c.Assert(err, check.IsNil)
team := &auth.Team{Name: "newteam", Users: []string{user.Email}}
err = s.conn.Teams().Insert(team)
c.Assert(err, check.IsNil)
token, err := nativeScheme.Login(map[string]string{"email": user.Email, "password": "123456"})
c.Assert(err, check.IsNil)
a := app.App{Name: "g1", Platform: "python", Teams: []string{team.Name}}
err = app.CreateApp(&a, user)
c.Assert(err, check.IsNil)
defer app.Delete(&a)
var result []app.DeployData
request, err := http.NewRequest("GET", "/deploys", nil)
c.Assert(err, check.IsNil)
recorder := httptest.NewRecorder()
timestamp := time.Date(2013, time.November, 1, 0, 0, 0, 0, time.Local)
duration := time.Since(timestamp)
err = s.conn.Deploys().Insert(app.DeployData{App: "g1", Timestamp: timestamp.Add(time.Minute), Duration: duration})
c.Assert(err, check.IsNil)
err = s.conn.Deploys().Insert(app.DeployData{App: "ge", Timestamp: timestamp.Add(time.Second), Duration: duration})
c.Assert(err, check.IsNil)
defer s.conn.Deploys().RemoveAll(nil)
request.Header.Set("Authorization", "bearer "+token.GetValue())
server := RunServer(true)
server.ServeHTTP(recorder, request)
c.Assert(recorder.Code, check.Equals, http.StatusOK)
err = json.Unmarshal(recorder.Body.Bytes(), &result)
c.Assert(err, check.IsNil)
c.Assert(result[0].ID, check.NotNil)
c.Assert(result[0].App, check.Equals, "g1")
c.Assert(result[0].Timestamp.In(time.UTC), check.DeepEquals, timestamp.Add(time.Minute).In(time.UTC))
c.Assert(result[0].Duration, check.DeepEquals, duration)
}
开发者ID:keymon,项目名称:tsuru,代码行数:37,代码来源:deploy_test.go
示例19: createUserAndTeam
func (s *S) createUserAndTeam(c *check.C) {
// TODO: remove this token from the suite, each test should create their
// own user with specific permissions.
s.token = customUserWithPermission(c, "super-root-toremove", permission.Permission{
Scheme: permission.PermAll,
Context: permission.Context(permission.CtxGlobal, ""),
})
var err error
s.user, err = s.token.User()
c.Assert(err, check.IsNil)
s.team = &auth.Team{Name: "tsuruteam"}
err = s.conn.Teams().Insert(s.team)
c.Assert(err, check.IsNil)
}
var nativeScheme = auth.ManagedScheme(native.NativeScheme{})
func (s *S) SetUpSuite(c *check.C) {
err := config.ReadConfigFile("testdata/config.yaml")
c.Assert(err, check.IsNil)
config.Set("database:url", "127.0.0.1:27017")
config.Set("database:name", "tsuru_api_base_test")
app.LogPubSubQueuePrefix = "pubsub:api-base-test:"
}
func (s *S) SetUpTest(c *check.C) {
routertest.FakeRouter.Reset()
repositorytest.Reset()
var err error
s.conn, err = db.Conn()
c.Assert(err, check.IsNil)
开发者ID:pedrosnk,项目名称:tsuru,代码行数:31,代码来源:suite_test.go
注:本文中的github.com/tsuru/tsuru/auth.ManagedScheme函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论