Exemple #1
0
func TestPasswordRetrievesCommandParamsFromPassgoRegistrar(t *testing.T) {
	Convey("Given a Password Command that receives its command params "+
		"from the Passgo registrar", t, func() {
		passgo := app.Null()
		passgo = registerPasswordCommandParamsWithPassgoRegistrar(passgo)
		command := NewPassword()
		Convey("when we apply those flags to the Password Command", func() {
			err := command.ApplyCommandParamsFrom(passgo)

			Convey("we should not receive an error", func() {

				So(err, ShouldBeNil)
			})

			Convey("the value of the password-length flag in Password should equal "+
				"what was provided to the Passgo registrar", func() {

				So(command.passwordLength.Value(), ShouldEqual, 10)
			})

			Convey("the value of the no-symbols flag in Password should equal "+
				"what was provided to the Passgo registrar", func() {

				So(command.noSymbols.Value(), ShouldEqual, false)
			})
		})

	})
}
Exemple #2
0
func TestGenerateCommandRetrievesCommandFlagsFromPassgoRegistrar(t *testing.T) {
	Convey("Given a Generate Command that receives its command flags "+
		"from a Passgo registrar", t, func() {
		passgo := app.Null()
		passgo = registerGenerateCommandFlagsWithPassgoRegistrar(passgo)
		command := NewGenerate()

		Convey("when the Passgo registrar that its trying to receive "+
			"its command flags from is nil", func() {
			err := command.ApplyCommandParamsFrom(nil)

			Convey("we should receive an error", func() {

				So(err, ShouldNotBeNil)
			})

		})

		// TODO: this convey could be compacted into a for loop
		Convey("when we apply those flags to the Generate Command", func() {
			err := command.ApplyCommandParamsFrom(passgo)

			Convey("we should not receive an error", func() {

				So(err, ShouldBeNil)
			})

			Convey("the value of the user-name flag in the Generate command "+
				"should equal the value of the user-name flag that "+
				"was provided to the Passgo registrar", func() {

				So(command.userName.Value(), ShouldEqual, "zap_rowsdower")

			})

			Convey("the value of the url flag in the Generate command "+
				"should equal the value of the url flag that "+
				"was provided to the Passgo registrar", func() {

				So(command.url.Value(), ShouldEqual, "https://cip.li")
			})

			Convey("the value of the password-length flag in the Generate command "+
				"should equal the value of the password-length flag that "+
				"was provided to the Passgo registrar", func() {

				So(command.passwordLength.Value(), ShouldEqual, 10)
			})

			Convey("the value of the no-symbols flag in the Generate command "+
				"should equal the value of the no-symbols flag that "+
				"was provided to the Passgo registrar", func() {

				So(command.noSymbols.Value(), ShouldEqual, false)
			})
		})

	})
}
Exemple #3
0
// NewStamp returns a stamp command with default values.
func NewStamp() *Stamp {
	stamp := &Stamp{
		App:     app.Null(),
		impl:    NewScrypt(),
		name:    "stamp",
		postage: stamp.NewPostage(),
	}
	stamp.execute = stampExecuteFn(stamp)
	return stamp
}
Exemple #4
0
// NewPassword returns a password command with default values.
func NewPassword() *Password {
	password := &Password{
		name:           "password",
		noSymbols:      password.NewNoSymbols(),
		passwordLength: password.NewLength(),
		App:            app.Null(),
	}
	password.execute = passwordExecuteFn(password)
	return password
}
Exemple #5
0
// NewGenerate returns a secret with default values
func NewGenerate() *Generate {
	generate := &Generate{
		App:            app.Null(),
		name:           "generate",
		noSymbols:      password.NewNoSymbols(),
		passwordLength: password.NewLength(),
		url:            generate.NewUrl(),
		userName:       generate.NewUserName(),
	}
	generate.execute = generateExecuteFn(generate)
	return generate
}