Beispiel #1
0
func NewETCD(
	serializationFormat *format.Format,
	convergenceWorkersSize int,
	updateWorkersSize int,
	cryptor encryption.Cryptor,
	storeClient StoreClient,
	auctioneerClient auctioneer.Client,
	serviceClient bbs.ServiceClient,
	clock clock.Clock,
	repClientFactory rep.ClientFactory,
	taskCC taskworkpool.TaskCompletionClient,
) *ETCDDB {
	return &ETCDDB{
		format:                 serializationFormat,
		convergenceWorkersSize: convergenceWorkersSize,
		updateWorkersSize:      updateWorkersSize,
		serializer:             format.NewSerializer(cryptor),
		client:                 storeClient,
		clock:                  clock,
		inflightWatches:        map[chan bool]bool{},
		inflightWatchLock:      &sync.Mutex{},
		auctioneerClient:       auctioneerClient,
		repClientFactory:       repClientFactory,
		taskCompletionClient:   taskCC,
		serviceClient:          serviceClient,
	}
}
Beispiel #2
0
func NewETCDHelper(serializationFormat *format.Format, cryptor encryption.Cryptor, client etcd.StoreClient) *ETCDHelper {
	logger := lagertest.NewTestLogger("etcd-helper")

	return &ETCDHelper{
		client:     client,
		format:     serializationFormat,
		serializer: format.NewSerializer(cryptor),
		logger:     logger,
	}
}
Beispiel #3
0
func NewETCD(
	serializationFormat *format.Format,
	convergenceWorkersSize int,
	updateWorkersSize int,
	desiredLRPCreationTimeout time.Duration,
	cryptor encryption.Cryptor,
	storeClient StoreClient,
	clock clock.Clock,
) *ETCDDB {
	return &ETCDDB{
		format:                    serializationFormat,
		convergenceWorkersSize:    convergenceWorkersSize,
		updateWorkersSize:         updateWorkersSize,
		desiredLRPCreationTimeout: desiredLRPCreationTimeout,
		serializer:                format.NewSerializer(cryptor),
		cryptor:                   cryptor,
		client:                    storeClient,
		clock:                     clock,
		inflightWatches:           map[chan bool]bool{},
		inflightWatchLock:         &sync.Mutex{},
	}
}
Beispiel #4
0
func NewSQLDB(
	db *sql.DB,
	convergenceWorkersSize int,
	updateWorkersSize int,
	serializationFormat *format.Format,
	cryptor encryption.Cryptor,
	guidProvider guidprovider.GUIDProvider,
	clock clock.Clock,
	flavor string,
) *SQLDB {
	return &SQLDB{
		db: db,
		convergenceWorkersSize: convergenceWorkersSize,
		updateWorkersSize:      updateWorkersSize,
		clock:                  clock,
		format:                 serializationFormat,
		guidProvider:           guidProvider,
		serializer:             format.NewSerializer(cryptor),
		cryptor:                cryptor,
		flavor:                 flavor,
	}
}
		migration  migration.Migration
		serializer format.Serializer
		cryptor    encryption.Cryptor

		logger *lagertest.TestLogger
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")

		encryptionKey, err := encryption.NewKey("label", "passphrase")
		Expect(err).NotTo(HaveOccurred())
		keyManager, err := encryption.NewKeyManager(encryptionKey, nil)
		Expect(err).NotTo(HaveOccurred())
		cryptor = encryption.NewCryptor(keyManager, rand.Reader)
		serializer = format.NewSerializer(cryptor)
		migration = migrations.NewBase64ProtobufEncode()
	})

	It("appends itself to the migration list", func() {
		Expect(migrations.Migrations).To(ContainElement(migration))
	})

	Describe("Version", func() {
		It("returns the timestamp from which it was created", func() {
			Expect(migration.Version()).To(BeEquivalentTo(1441411196))
		})
	})

	Describe("Up", func() {
		var (
func (b *TimeoutToMilliseconds) SetCryptor(cryptor encryption.Cryptor) {
	b.serializer = format.NewSerializer(cryptor)
}
Beispiel #7
0
				bbsArgs.ActiveKeyLabel = "label"
				bbsArgs.EncryptionKeys = []string{"label:some phrase"}
			})

			It("writes the value as base64 encoded encrypted protobufs with metadata", func() {
				res, err := etcdClient.Get(etcddb.TaskSchemaPathByGuid(task.TaskGuid), false, false)
				Expect(err).NotTo(HaveOccurred())

				var decodedTask models.Task

				encryptionKey, err := encryption.NewKey("label", "some phrase")
				Expect(err).NotTo(HaveOccurred())
				keyManager, err := encryption.NewKeyManager(encryptionKey, nil)
				Expect(err).NotTo(HaveOccurred())
				cryptor := encryption.NewCryptor(keyManager, rand.Reader)
				serializer := format.NewSerializer(cryptor)

				encoding := res.Node.Value[:format.EnvelopeOffset]
				Expect(format.Encoding{encoding[0], encoding[1]}).To(Equal(format.BASE64_ENCRYPTED))
				err = serializer.Unmarshal(logger, []byte(res.Node.Value), &decodedTask)
				Expect(err).NotTo(HaveOccurred())

				Expect(task.TaskGuid).To(Equal(decodedTask.TaskGuid))
			})

		})

		Context("when provided a multiple encryption keys", func() {
			BeforeEach(func() {
				bbsArgs.ActiveKeyLabel = "newkey"
				bbsArgs.EncryptionKeys = []string{
func (m *SplitDesiredLRP) SetCryptor(cryptor encryption.Cryptor) {
	m.serializer = format.NewSerializer(cryptor)
}
func (b *Base64ProtobufEncode) SetCryptor(cryptor encryption.Cryptor) {
	b.serializer = format.NewSerializer(cryptor)
}