func appendOpenID(t *testing.T, stmt *gabs.Container) *gabs.Container {
	stmt, err := gabs.ParseJSON([]byte(stmt.String()))
	fatalIfError(t, err)

	domainPrefix := uuid.NewV4().String()
	openID := "http://" + domainPrefix + ".openid.example.com/"
	_, err = stmt.SetP(openID, "actor.openid")
	fatalIfError(t, err)

	return stmt
}
func appendMbox(t *testing.T, stmt *gabs.Container) *gabs.Container {
	stmt, err := gabs.ParseJSON([]byte(stmt.String()))
	fatalIfError(t, err)

	domainPrefix := uuid.NewV4().String()
	mbox := "mbox:test@" + domainPrefix + ".example.com"
	_, err = stmt.SetP(mbox, "actor.mbox")
	fatalIfError(t, err)

	return stmt
}
func appendMboxSHA1(t *testing.T, stmt *gabs.Container) *gabs.Container {
	stmt, err := gabs.ParseJSON([]byte(stmt.String()))
	fatalIfError(t, err)

	data := make([]byte, 16)
	_, err = rand.Read(data)
	fatalIfError(t, err)
	mboxSHA1 := fmt.Sprintf("%x", sha1.Sum(data))
	_, err = stmt.SetP(mboxSHA1, "actor.mbox_sha1sum")
	fatalIfError(t, err)

	return stmt
}
func appendAccount(t *testing.T, stmt *gabs.Container) *gabs.Container {
	stmt, err := gabs.ParseJSON([]byte(stmt.String()))
	fatalIfError(t, err)

	suffix := uuid.NewV4().String()
	name := "name-example-" + suffix
	homePage := "http://example.com"
	_, err = stmt.SetP(name, "actor.account.name")
	fatalIfError(t, err)
	_, err = stmt.SetP(homePage, "actor.account.homePage")
	fatalIfError(t, err)

	return stmt
}
示例#5
0
// Merge ("generate?") guest network configuration from host configuration.
func mergeNetConfig(netconfig *netConfig, guest *gabs.Container) (err error) {
	if guest.ExistsP("hostname") {
		log.Print("Guest already defines hostname, not overriden")
	} else {
		guest.SetP(netconfig.hostname, "hostname")
	}
	if guest.ExistsP("net") {
		return fmt.Errorf("Guest already defines net configuration")
	}
	addrs, _ := guest.ArrayOfSizeP(1, "net.interfaces.vioif0.addrs")
	addr, _ := addrs.ObjectI(0)
	addr.Set("inet", "type")
	addr.Set("static", "method")
	addr.Set(netconfig.ipAddress, "addr")
	gateways, _ := guest.ArrayOfSizeP(1, "net.gateways")
	gw, _ := gateways.ObjectI(0)
	gw.Set("inet", "type")
	gw.Set(netconfig.gateway, "addr")
	dns, _ := guest.ObjectP("net.dns")
	dns.Set(netconfig.dnsServers, "nameservers")
	dns.Set(netconfig.dnsSearch, "search")
	return
}
示例#6
0
func cleanToken(token *gabs.Container) {
	token.SetP(html.EscapeString(token.Path("nick").Data().(string)), "nick")
	token.SetP(html.EscapeString(token.Path("uid").Data().(string)), "uid")
	token.SetP(html.EscapeString(token.Path("name").Data().(string)), "name")
	token.SetP(html.EscapeString(token.Path("email").Data().(string)), "email")
	token.SetP(html.EscapeString(token.Path("phone").Data().(string)), "phone")
	token.SetP(html.EscapeString(token.Path("url").Data().(string)), "url")
	token.SetP(html.EscapeString(token.Path("desc").Data().(string)), "desc")
	token.SetP(html.EscapeString(token.Path("avatar").Data().(string)), "avatar")
}