Ejemplo n.º 1
0
func MakeInstitution() *models.Institution {
	return &models.Institution{
		Id:         rand.Intn(50000) + 1,
		Name:       fake.Product(),
		BriefName:  fake.Word(),
		Identifier: fake.DomainName(),
	}
}
Ejemplo n.º 2
0
// WebhookEntity returns a new random valid webhook
func WebhookEntity() (result entity.Webhook) {
	var err error
	result.URL, err = url.Parse("http://" + fake.DomainName())
	if err != nil {
		panic(err)
	}

	kp, err := keypair.Random()
	if err != nil {
		panic(err)
	}

	result.DestinationFilter = entity.AccountID(kp.Address())
	return
}
Ejemplo n.º 3
0
func TestInternet(t *testing.T) {
	for _, lang := range fake.GetLangs() {
		fake.SetLang(lang)

		v := fake.UserName()
		if v == "" {
			t.Errorf("UserName failed with lang %s", lang)
		}

		v = fake.TopLevelDomain()
		if v == "" {
			t.Errorf("TopLevelDomain failed with lang %s", lang)
		}

		v = fake.DomainName()
		if v == "" {
			t.Errorf("DomainName failed with lang %s", lang)
		}

		v = fake.EmailAddress()
		if v == "" {
			t.Errorf("EmailAddress failed with lang %s", lang)
		}

		v = fake.EmailSubject()
		if v == "" {
			t.Errorf("EmailSubject failed with lang %s", lang)
		}

		v = fake.EmailBody()
		if v == "" {
			t.Errorf("EmailBody failed with lang %s", lang)
		}

		v = fake.DomainZone()
		if v == "" {
			t.Errorf("DomainZone failed with lang %s", lang)
		}

		v = fake.IPv4()
		if v == "" {
			t.Errorf("IPv4 failed with lang %s", lang)
		}
	}
}
Ejemplo n.º 4
0
// MakeDPNNode creates a mock DPN node object for testing.
func MakeDPNNode() *models.Node {
	return &models.Node{
		Name:      fake.Word(),
		Namespace: fake.Word(),
		APIRoot:   fmt.Sprintf("https://", fake.DomainName()),
		SSHPubKey: fake.Word(),
		CreatedAt: apt_testutil.RandomDateTime(),
		UpdatedAt: apt_testutil.RandomDateTime(),
		Protocols: []string{"rsync"},
		Storage: &models.Storage{
			Region: "palookaville",
			Type:   "shoe box",
		},
		FixityAlgorithms: []string{"sha256"},
		ReplicateFrom:    []string{"aptrust", "chron", "sdr", "tdr"},
		ReplicateTo:      []string{"aptrust", "chron", "sdr", "tdr"},
		RestoreFrom:      []string{"aptrust", "chron", "sdr", "tdr"},
		RestoreTo:        []string{"aptrust", "chron", "sdr", "tdr"},
	}
}
Ejemplo n.º 5
0
func genFakeData(v *Value) interface{} {
	if len(v.Tags) == 0 {
		return v.Data
	}

	typ, ok := v.Tags.Get("type")
	if !ok {
		return v.Data
	}
	switch typ {
	case fieldTags.Brand:
		return fake.Brand()
	case fieldTags.Character:
		return fake.Character()
	case fieldTags.Characters:
		return fieldTags.Characters
	case fieldTags.CharactersN:
		max := 5
		if m, err := v.Tags.Int("max"); err == nil {
			max = m
		}
		return fake.CharactersN(max)
	case fieldTags.City:
		return fake.City()
	case fieldTags.Color:
		return fake.Color()
	case fieldTags.Company:
		return fake.Company()
	case fieldTags.Continent:
		return fake.Continent()
	case fieldTags.Country:
		return fake.Country()
	case fieldTags.CreditCardNum:
		vendor, _ := v.Tags.Get("vendor")
		fake.CreditCardNum(vendor)
	case fieldTags.Currency:
		fake.Currency()
	case fieldTags.CurrencyCode:
		fake.CurrencyCode()
	case fieldTags.Day:
		return fake.Day()
	case fieldTags.Digits:
		return fake.Digits()
	case fieldTags.DigitsN:
		max := 5
		if m, err := v.Tags.Int("max"); err == nil {
			max = m
		}
		return fake.DigitsN(max)
	case fieldTags.DomainName:
		return fake.DomainName()
	case fieldTags.DomainZone:
		return fake.DomainZone()
	case fieldTags.EmailAddress:
		return fake.EmailAddress()
	case fieldTags.EmailBody:
		return fake.EmailBody()
	case fieldTags.FemaleFirstName:
		return fake.FemaleFirstName()
	case fieldTags.FemaleFullName:
		return fake.FemaleFullName()
	case fieldTags.FemaleFullNameWithPrefix:
		return fake.FemaleFullNameWithPrefix()
	case fieldTags.FemaleFullNameWithSuffix:
		return fake.FemaleFullNameWithSuffix()
	case fieldTags.FemaleLastName:
		return fake.FemaleLastName()
	case fieldTags.FemaleLastNamePratronymic:
		return fake.FemalePatronymic()
	case fieldTags.FirstName:
		return fake.FirstName()
	case fieldTags.FullName:
		return fake.FullName()
	case fieldTags.FullNameWithPrefix:
		return fake.FullNameWithPrefix()
	case fieldTags.FullNameWithSuffix:
		return fake.FullNameWithSuffix()
	case fieldTags.Gender:
		return fake.Gender()
	case fieldTags.GenderAbrev:
		return fake.GenderAbbrev()
	case fieldTags.HexColor:
		return fake.HexColor()
	case fieldTags.HexColorShort:
		return fake.HexColorShort()
	case fieldTags.IPv4:
		return fake.IPv4()
	case fieldTags.Industry:
		return fake.Industry()
	case fieldTags.JobTitle:
		return fake.JobTitle()
	case fieldTags.Language:
		return fake.Language()
	case fieldTags.LastName:
		return fake.LastName()
	case fieldTags.LatitudeDegrees:
		return fake.LatitudeDegress()
	case fieldTags.LatitudeDirection:
		return fake.LatitudeDirection()
	case fieldTags.LatitudeMinutes:
		return fake.LatitudeMinutes()
	case fieldTags.LatitudeSeconds:
		return fake.LatitudeSeconds()
	case fieldTags.Latitude:
		return fake.Latitute()
	case fieldTags.LongitudeDegrees:
		return fake.LongitudeDegrees()
	case fieldTags.LongitudeDirection:
		return fake.LongitudeDirection()
	case fieldTags.LongitudeMinutes:
		return fake.LongitudeMinutes()
	case fieldTags.LongitudeSeconds:
		return fake.LongitudeSeconds()
	case fieldTags.MaleFirstName:
		return fake.MaleFirstName()
	case fieldTags.MaleFullNameWithPrefix:
		return fake.MaleFullNameWithPrefix()
	case fieldTags.MaleFullNameWithSuffix:
		return fake.MaleFullNameWithSuffix()
	case fieldTags.MaleLastName:
		return fake.MaleLastName()
	case fieldTags.MalePratronymic:
		return fake.MalePatronymic()
	case fieldTags.Model:
		return fake.Model()
	case fieldTags.Month:
		return fake.Month()
	case fieldTags.MonthNum:
		return fake.MonthNum()
	case fieldTags.MonthShort:
		return fake.MonthShort()
	case fieldTags.Paragraph:
		return fake.Paragraph()
	case fieldTags.Patagraphs:
		return fake.Paragraphs()
	case fieldTags.PatagraphsN:
		max := 5
		if m, err := v.Tags.Int("max"); err == nil {
			max = m
		}
		return fake.ParagraphsN(max)
	case fieldTags.Password:
		var (
			atLeast                                = 5
			atMost                                 = 8
			allowUpper, allowNumeric, allowSpecial = true, true, true
		)
		if least, err := v.Tags.Int("at_least"); err == nil {
			atLeast = least
		}
		if most, err := v.Tags.Int("at_most"); err == nil {
			atMost = most
		}
		if upper, err := v.Tags.Bool("upper"); err == nil {
			allowUpper = upper
		}
		if numeric, err := v.Tags.Bool("numeric"); err == nil {
			allowNumeric = numeric
		}
		if special, err := v.Tags.Bool("special"); err == nil {
			allowSpecial = special
		}
		return fake.Password(atLeast, atMost, allowUpper, allowNumeric, allowSpecial)
	case fieldTags.Patronymic:
		return fake.Patronymic()
	case fieldTags.Phone:
		return fake.Phone()
	case fieldTags.Product:
		return fake.Product()
	case fieldTags.ProductName:
		return fake.ProductName()
	case fieldTags.Sentence:
		return fake.Sentence()
	case fieldTags.Sentences:
		return fake.Sentence()
	case fieldTags.SentencesN:
		max := 5
		if m, err := v.Tags.Int("max"); err == nil {
			max = m
		}
		return fake.SentencesN(max)
	case fieldTags.SimplePassWord:
		return fake.SimplePassword()
	case fieldTags.State:
		return fake.State()
	case fieldTags.StateAbbrev:
		return fake.StateAbbrev()
	case fieldTags.Street:
		return fake.Street()
	case fieldTags.StreetAddress:
		return fake.StreetAddress()
	case fieldTags.Title:
		return fake.Title()
	case fieldTags.TopLevelDomain:
		return fake.TopLevelDomain()
	case fieldTags.UserName:
		return fake.UserName()
	case fieldTags.WeekDay:
		return fake.WeekDay()
	case fieldTags.WeekDayNum:
		return fake.WeekdayNum()
	case fieldTags.WeekDayShort:
		return fake.WeekDayShort()
	case fieldTags.Word:
		return fake.Word()
	case fieldTags.Words:
		return fake.Words()
	case fieldTags.WordsN:
		max := 5
		if m, err := v.Tags.Int("max"); err == nil {
			max = m
		}
		return fake.WordsN(max)
	case fieldTags.Year:
	//return fake.Year()
	case fieldTags.Zip:
		return fake.Zip()
	}

	return v.Data
}
Ejemplo n.º 6
0
// DomainName generates random domain name
func (s *Stabber) DomainName() string {
	return fake.DomainName()
}
Ejemplo n.º 7
0
func RandomObjectIdentifier() string {
	return fmt.Sprintf("%s/%s", fake.DomainName(), fake.FemalePatronymic())
}
Ejemplo n.º 8
0
func genFakeData(v *Value, kind string) interface{} {
	if len(v.Tags) == 0 {
		return v.Data
	}

	typ, ok := v.Tags["type"]
	if !ok {
		return v.Data
	}
	switch typ {
	case fieldTags.Brand:
		return fake.Brand()
	case fieldTags.Character:
		return fake.Character()
	case fieldTags.Characters:
		return fieldTags.Characters
	case fieldTags.CharactersN:
		return fake.CharactersN(5)
	case fieldTags.City:
		return fake.City()
	case fieldTags.Color:
		return fake.Color()
	case fieldTags.Company:
		return fake.Company()
	case fieldTags.Continent:
		return fake.Continent()
	case fieldTags.Country:
		return fake.Country()
	case fieldTags.CreditCardNum:
		fake.CreditCardNum("vendor")
	case fieldTags.Currency:
		fake.Currency()
	case fieldTags.CurrencyCode:
		fake.CurrencyCode()
	case fieldTags.Day:
		return fake.Day()
	case fieldTags.Digits:
		return fake.Digits()
	case fieldTags.DigitsN:
		return fake.DigitsN(5)
	case fieldTags.DomainName:
		return fake.DomainName()
	case fieldTags.DomainZone:
		return fake.DomainZone()
	case fieldTags.EmailAddress:
		return fake.EmailAddress()
	case fieldTags.EmailBody:
		return fake.EmailBody()
	case fieldTags.FemaleFirstName:
		return fake.FemaleFirstName()
	case fieldTags.FemaleFullName:
		return fake.FemaleFullName()
	case fieldTags.FemaleFullNameWithPrefix:
		return fake.FemaleFullNameWithPrefix()
	case fieldTags.FemaleFullNameWithSuffix:
		return fake.FemaleFullNameWithSuffix()
	case fieldTags.FemaleLastName:
		return fake.FemaleLastName()
	case fieldTags.FemaleLastNamePratronymic:
		return fake.FemalePatronymic()
	case fieldTags.FirstName:
		return fake.FirstName()
	case fieldTags.FullName:
		return fake.FullName()
	case fieldTags.FullNameWithPrefix:
		return fake.FullNameWithPrefix()
	case fieldTags.FullNameWithSuffix:
		return fake.FullNameWithSuffix()
	case fieldTags.Gender:
		return fake.Gender()
	case fieldTags.GenderAbrev:
		return fake.GenderAbbrev()
	case fieldTags.HexColor:
		return fake.HexColor()
	case fieldTags.HexColorShort:
		return fake.HexColorShort()
	case fieldTags.IPv4:
		return fake.IPv4()
	case fieldTags.Industry:
		return fake.Industry()
	case fieldTags.JobTitle:
		return fake.JobTitle()
	case fieldTags.Language:
		return fake.Language()
	case fieldTags.LastName:
		return fake.LastName()
	case fieldTags.LatitudeDegrees:
		return fake.LatitudeDegress()
	case fieldTags.LatitudeDirection:
		return fake.LatitudeDirection()
	case fieldTags.LatitudeMinutes:
		return fake.LatitudeMinutes()
	case fieldTags.LatitudeSeconds:
		return fake.LatitudeSeconds()
	case fieldTags.Latitude:
		return fake.Latitute()
	case fieldTags.LongitudeDegrees:
		return fake.LongitudeDegrees()
	case fieldTags.LongitudeDirection:
		return fake.LongitudeDirection()
	case fieldTags.LongitudeMinutes:
		return fake.LongitudeMinutes()
	case fieldTags.LongitudeSeconds:
		return fake.LongitudeSeconds()
	case fieldTags.MaleFirstName:
		return fake.MaleFirstName()
	case fieldTags.MaleFullNameWithPrefix:
		return fake.MaleFullNameWithPrefix()
	case fieldTags.MaleFullNameWithSuffix:
		return fake.MaleFullNameWithSuffix()
	case fieldTags.MaleLastName:
		return fake.MaleLastName()
	case fieldTags.MalePratronymic:
		return fake.MalePatronymic()
	case fieldTags.Model:
		return fake.Model()
	case fieldTags.Month:
		return fake.Month()
	case fieldTags.MonthNum:
		return fake.MonthNum()
	case fieldTags.MonthShort:
		return fake.MonthShort()
	case fieldTags.Paragraph:
		return fake.Paragraph()
	case fieldTags.Patagraphs:
		return fake.Paragraphs()
	case fieldTags.PatagraphsN:
		return fake.ParagraphsN(4)
	case fieldTags.Password:
	//return fake.Password()
	case fieldTags.Patronymic:
		return fake.Patronymic()
	case fieldTags.Phone:
		return fake.Phone()
	case fieldTags.Product:
		return fake.Product()
	case fieldTags.ProductName:
		return fake.ProductName()
	case fieldTags.Sentence:
		return fake.Sentence()
	case fieldTags.Sentences:
		return fake.Sentence()
	case fieldTags.SentencesN:
		return fake.SentencesN(4)
	case fieldTags.SimplePassWord:
		return fake.SimplePassword()
	case fieldTags.State:
		return fake.State()
	case fieldTags.StateAbbrev:
		return fake.StateAbbrev()
	case fieldTags.Street:
		return fake.Street()
	case fieldTags.StreetAddress:
		return fake.StreetAddress()
	case fieldTags.Title:
		return fake.Title()
	case fieldTags.TopLevelDomain:
		return fake.TopLevelDomain()
	case fieldTags.UserName:
		return fake.UserName()
	case fieldTags.WeekDay:
		return fake.WeekDay()
	case fieldTags.WeekDayNum:
		return fake.WeekdayNum()
	case fieldTags.WeekDayShort:
		return fake.WeekDayShort()
	case fieldTags.Word:
		return fake.Word()
	case fieldTags.Words:
		return fake.Words()
	case fieldTags.WordsN:
		return fake.WordsN(4)
	case fieldTags.Year:
	//return fake.Year()
	case fieldTags.Zip:
		return fake.Zip()
	}

	return v.Data
}