Пример #1
0
func TestMain(m *testing.M) {
	// open database in memory for testing
	mailbox.OpenMemDB()
	err := mailbox.CreateDB()
	if err != nil {
		panic(err)
	}

	// create a default mailbox to use
	mb, err = mailbox.Create("mb")
	if err != nil {
		panic(err)
	}

	// create an access token for the default mailbox
	accessKey = &mailbox.AccessKey{FullAccess: true}
	accessKey.Create()

	// create a postmasterClient
	pmClient = client.Client{
		Host:          "localhost:4111",
		Mailbox:       mb.Id,
		AccessKeyName: accessKey.Name,
		AccessKey:     accessKey.Secret,
	}

	// Start up a test server to use
	server.EnableLongPolling = false
	go server.Start(":4111")
	retCode := m.Run()

	// cleanup
	mailbox.CloseDB()
	os.Exit(retCode)
}
Пример #2
0
func TestMain(m *testing.M) {
	mailbox.OpenMemDB()
	mailbox.CreateDB()

	retCode := m.Run()

	mailbox.CloseDB()
	os.Exit(retCode)
}
Пример #3
0
func TestServerPurge(t *testing.T) {
	mb, _ := mailbox.Create("purge.test")
	msg, _ := mb.PutMessage("tesT")
	if msg == nil {
		t.Fatal("Message not deployed")
	}
	mailbox.CloseDB()
	purgeCmd.Run(purgeCmd, []string{"purge.test"})
	msg, _ = mb.GetMessage()
	if msg != nil {
		t.Fatal("Message was not purged")
	}
}
Пример #4
0
func TestMain(m *testing.M) {
	mailbox.OpenMemDB()
	mailbox.CreateDB()

	server.EnableLongPolling = false
	server.ThrottleDelay = 0

	go server.Start(":4111")

	retCode := m.Run()

	mailbox.CloseDB()
	os.Exit(retCode)
}
Пример #5
0
	"conduit/log"
	"github.com/spf13/cobra"
	"postmaster/mailbox"
)

// acessListCmd represents the acessList command
var accessListCmd = &cobra.Command{
	Use:   "list",
	Short: "List all administrative access keys",
	Long: `Display a list of all administrative access keys that have been
generated using 'conduit server access'. The server must be stopped when
running this command.`,
	Run: func(cmd *cobra.Command, args []string) {
		mailbox.OpenDB()
		keys, err := mailbox.AdminKeys()
		if err != nil {
			log.Debug(err.Error())
			log.Fatal("Could not list keys")
		}
		log.Alert("Access keys:")
		for _, k := range keys {
			log.Info(k.Name)
		}
		mailbox.CloseDB()
	},
}

func init() {
	accessCmd.AddCommand(accessListCmd)
}