コード例 #1
0
ファイル: password_test.go プロジェクト: sdaros/passgo
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)
			})
		})

	})
}
コード例 #2
0
ファイル: generate_test.go プロジェクト: sdaros/passgo
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)
			})
		})

	})
}
コード例 #3
0
ファイル: stamp.go プロジェクト: sdaros/passgo
// 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
}
コード例 #4
0
ファイル: password.go プロジェクト: sdaros/passgo
// 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
}
コード例 #5
0
ファイル: generate.go プロジェクト: sdaros/passgo
// 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
}