text:
package firestore // import "google.golang.org/genproto/googleapis/firestore/v1beta1"

import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import timestamp "github.com/golang/protobuf/ptypes/timestamp"
import _ "google.golang.org/genproto/googleapis/api/annotations"

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package

// A value that is calculated by the server.
type DocumentTransform_FieldTransform_ServerValue int32

const (
	// Unspecified. This value must not be used.
	DocumentTransform_FieldTransform_SERVER_VALUE_UNSPECIFIED DocumentTransform_FieldTransform_ServerValue = 0
	// The time at which the server processed the request, with millisecond
	// precision.
	DocumentTransform_FieldTransform_REQUEST_TIME DocumentTransform_FieldTransform_ServerValue = 1
)

var DocumentTransform_FieldTransform_ServerValue_name = map[int32]string{
	0: "SERVER_VALUE_UNSPECIFIED",
	1: "REQUEST_TIME",
}
var DocumentTransform_FieldTransform_ServerValue_value = map[string]int32{
	"SERVER_VALUE_UNSPECIFIED": 0,
	"REQUEST_TIME":             1,
}

func (x DocumentTransform_FieldTransform_ServerValue) String() string {
	return proto.EnumName(DocumentTransform_FieldTransform_ServerValue_name, int32(x))
}
func (DocumentTransform_FieldTransform_ServerValue) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_write_f7b2ce45bbcfd263, []int{1, 0, 0}
}

// A write on a document.
type Write struct {
	// The operation to execute.
	//
	// Types that are valid to be assigned to Operation:
	//	*Write_Update
	//	*Write_Delete
	//	*Write_Transform
	Operation isWrite_Operation `protobuf_oneof:"operation"`
	// The fields to update in this write.
	//
	// This field can be set only when the operation is `update`.
	// If the mask is not set for an `update` and the document exists, any
	// existing data will be overwritten.
	// If the mask is set and the document on the server has fields not covered by
	// the mask, they are left unchanged.
	// Fields referenced in the mask, but not present in the input document, are
	// deleted from the document on the server.
	// The field paths in this mask must not contain a reserved field name.
	UpdateMask *DocumentMask `protobuf:"bytes,3,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`
	// An optional precondition on the document.
	//
	// The write will fail if this is set and not met by the target document.
	CurrentDocument      *Precondition `protobuf:"bytes,4,opt,name=current_document,json=currentDocument,proto3" json:"current_document,omitempty"`
	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
	XXX_unrecognized     []byte        `json:"-"`
	XXX_sizecache        int32         `json:"-"`
}

func (m *Write) Reset()         { *m = Write{} }
func (m *Write) String() string { return proto.CompactTextString(m) }
func (*Write) ProtoMessage()    {}
func (*Write) Descriptor() ([]byte, []int) {
	return fileDescriptor_write_f7b2ce45bbcfd263, []int{0}
}
func (m *Write) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_Write.Unmarshal(m, b)
}
func (m *Write) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_Write.Marshal(b, m, deterministic)
}
func (dst *Write) XXX_Merge(src proto.Message) {
	xxx_messageInfo_Write.Merge(dst, src)
}
func (m *Write) XXX_Size() int {
	return xxx_messageInfo_Write.Size(m)
}
func (m *Write) XXX_DiscardUnknown() {
	xxx_messageInfo_Write.DiscardUnknown(m)
}

var xxx_messageInfo_Write proto.InternalMessageInfo

type isWrite_Operation interface {
	isWrite_Operation()
}

type Write_Update struct {
	Update *Document `protobuf:"bytes,1,opt,name=update,proto3,oneof"`
}

type Write_Delete struct {
	Delete string `protobuf:"bytes,2,opt,name=delete,proto3,oneof"`
}

type Write_Transform struct {
	Transform *DocumentTransform `protobuf:"bytes,6,opt,name=transform,proto3,oneof"`
}

func (*Write_Update) isWrite_Operation() {}

func (*Write_Delete) isWrite_Operation() {}

func (*Write_Transform) isWrite_Operation() {}

func (m *Write) GetOperation() isWrite_Operation {
	if m != nil {
		return m.Operation
	}
	return nil
}

func (m *Write) GetUpdate() *Document {
	if x, ok := m.GetOperation().(*Write_Update); ok {
		return x.Update
	}
	return nil
}

func (m *Write) GetDelete() string {
	if x, ok := m.GetOperation().(*Write_Delete); ok {
		return x.Delete
	}
	return ""
}

func (m *Write) GetTransform() *DocumentTransform {
	if x, ok := m.GetOperation().(*Write_Transform); ok {
		return x.Transform
	}
	return nil
}

func (m *Write) GetUpdateMask() *DocumentMask {
	if m != nil {
		return m.UpdateMask
	}
	return nil
}

func (m *Write) GetCurrentDocument() *Precondition {
	if m != nil {
		return m.CurrentDocument
	}
	return nil
}

// XXX_OneofFuncs is for the internal use of the proto package.
func (*Write) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
	return _Write_OneofMarshaler, _Write_OneofUnmarshaler, _Write_OneofSizer, []interface{}{
		(*Write_Update)(nil),
		(*Write_Delete)(nil),
		(*Write_Transform)(nil),
	}
}

func _Write_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Write)
	// operation
	switch x := m.Operation.(type) {
	case *Write_Update:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Update); err != nil {
			return err
		}
	case *Write_Delete:
		b.EncodeVarint(2<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Delete)
	case *Write_Transform:
		b.EncodeVarint(6<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Transform); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("Write.Operation has unexpected type %T", x)
	}
	return nil
}

func _Write_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*Write)
	switch tag {
	case 1: // operation.update
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Document)
		err := b.DecodeMessage(msg)
		m.Operation = &Write_Update{msg}
		return true, err
	case 2: // operation.delete
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeStringBytes()
		m.Operation = &Write_Delete{x}
		return true, err
	case 6: // operation.transform
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(DocumentTransform)
		err := b.DecodeMessage(msg)
		m.Operation = &Write_Transform{msg}
		return true, err
	default:
		return false, nil
	}
}

func _Write_OneofSizer(msg proto.Message) (n int) {
	m := msg.(*Write)
	// operation
	switch x := m.Operation.(type) {
	case *Write_Update:
		s := proto.Size(x.Update)
		n += 1 // tag and wire
		n += proto.SizeVarint(uint64(s))
		n += s
	case *Write_Delete:
		n += 1 // tag and wire
		n += proto.SizeVarint(uint64(len(x.Delete)))
		n += len(x.Delete)
	case *Write_Transform:
		s := proto.Size(x.Transform)
		n += 1 // tag and wire
		n += proto.SizeVarint(uint64(s))
		n += s
	case nil:
	default:
		panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
	}
	return n
}

// A transformation of a document.
type DocumentTransform struct {
	// The name of the document to transform.
	Document string `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"`
	// The list of transformations to apply to the fields of the document, in
	// order.
	// This must not be empty.
	FieldTransforms      []*DocumentTransform_FieldTransform `protobuf:"bytes,2,rep,name=field_transforms,json=fieldTransforms,proto3" json:"field_transforms,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                            `json:"-"`
	XXX_unrecognized     []byte                              `json:"-"`
	XXX_sizecache        int32                               `json:"-"`
}

func (m *DocumentTransform) Reset()         { *m = DocumentTransform{} }
func (m *DocumentTransform) String() string { return proto.CompactTextString(m) }
func (*DocumentTransform) ProtoMessage()    {}
func (*DocumentTransform) Descriptor() ([]byte, []int) {
	return fileDescriptor_write_f7b2ce45bbcfd263, []int{1}
}
func (m *DocumentTransform) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_DocumentTransform.Unmarshal(m, b)
}
func (m *DocumentTransform) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_DocumentTransform.Marshal(b, m, deterministic)
}
func (dst *DocumentTransform) XXX_Merge(src proto.Message) {
	xxx_messageInfo_DocumentTransform.Merge(dst, src)
}
func (m *DocumentTransform) XXX_Size() int {
	return xxx_messageInfo_DocumentTransform.Size(m)
}
func (m *DocumentTransform) XXX_DiscardUnknown() {
	xxx_messageInfo_DocumentTransform.DiscardUnknown(m)
}

var xxx_messageInfo_DocumentTransform proto.InternalMessageInfo

func (m *DocumentTransform) GetDocument() string {
	if m != nil {
		return m.Document
	}
	return ""
}

func (m *DocumentTransform) GetFieldTransforms() []*DocumentTransform_FieldTransform {
	if m != nil {
		return m.FieldTransforms
	}
	return nil
}

// A transformation of a field of the document.
type DocumentTransform_FieldTransform struct {
	// The path of the field. See
	// [Document.fields][google.firestore.v1beta1.Document.fields] for the field
	// path syntax reference.
	FieldPath string `protobuf:"bytes,1,opt,name=field_path,json=fieldPath,proto3" json:"field_path,omitempty"`
	// The transformation to apply on the field.
	//
	// Types that are valid to be assigned to TransformType:
	//	*DocumentTransform_FieldTransform_SetToServerValue
	//	*DocumentTransform_FieldTransform_Increment
	//	*DocumentTransform_FieldTransform_Maximum
	//	*DocumentTransform_FieldTransform_Minimum
	//	*DocumentTransform_FieldTransform_AppendMissingElements
	//	*DocumentTransform_FieldTransform_RemoveAllFromArray
	TransformType        isDocumentTransform_FieldTransform_TransformType `protobuf_oneof:"transform_type"`
	XXX_NoUnkeyedLiteral struct{}                                         `json:"-"`
	XXX_unrecognized     []byte                                           `json:"-"`
	XXX_sizecache        int32                                            `json:"-"`
}

func (m *DocumentTransform_FieldTransform) Reset()         { *m = DocumentTransform_FieldTransform{} }
func (m *DocumentTransform_FieldTransform) String() string { return proto.CompactTextString(m) }
func (*DocumentTransform_FieldTransform) ProtoMessage()    {}
func (*DocumentTransform_FieldTransform) Descriptor() ([]byte, []int) {
	return fileDescriptor_write_f7b2ce45bbcfd263, []int{1, 0}
}
func (m *DocumentTransform_FieldTransform) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_DocumentTransform_FieldTransform.Unmarshal(m, b)
}
func (m *DocumentTransform_FieldTransform) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_DocumentTransform_FieldTransform.Marshal(b, m, deterministic)
}
func (dst *DocumentTransform_FieldTransform) XXX_Merge(src proto.Message) {
	xxx_messageInfo_DocumentTransform_FieldTransform.Merge(dst, src)
}
func (m *DocumentTransform_FieldTransform) XXX_Size() int {
	return xxx_messageInfo_DocumentTransform_FieldTransform.Size(m)
}
func (m *DocumentTransform_FieldTransform) XXX_DiscardUnknown() {
	xxx_messageInfo_DocumentTransform_FieldTransform.DiscardUnknown(m)
}

var xxx_messageInfo_DocumentTransform_FieldTransform proto.InternalMessageInfo

func (m *DocumentTransform_FieldTransform) GetFieldPath() string {
	if m != nil {
		return m.FieldPath
	}
	return ""
}

type isDocumentTransform_FieldTransform_TransformType interface {
	isDocumentTransform_FieldTransform_TransformType()
}

type DocumentTransform_FieldTransform_SetToServerValue struct {
	SetToServerValue DocumentTransform_FieldTransform_ServerValue `protobuf:"varint,2,opt,name=set_to_server_value,json=setToServerValue,proto3,enum=google.firestore.v1beta1.DocumentTransform_FieldTransform_ServerValue,oneof"`
}

type DocumentTransform_FieldTransform_Increment struct {
	Increment *Value `protobuf:"bytes,3,opt,name=increment,proto3,oneof"`
}

type DocumentTransform_FieldTransform_Maximum struct {
	Maximum *Value `protobuf:"bytes,4,opt,name=maximum,proto3,oneof"`
}

type DocumentTransform_FieldTransform_Minimum struct {
	Minimum *Value `protobuf:"bytes,5,opt,name=minimum,proto3,oneof"`
}

type DocumentTransform_FieldTransform_AppendMissingElements struct {
	AppendMissingElements *ArrayValue `protobuf:"bytes,6,opt,name=append_missing_elements,json=appendMissingElements,proto3,oneof"`
}

type DocumentTransform_FieldTransform_RemoveAllFromArray struct {
	RemoveAllFromArray *ArrayValue `protobuf:"bytes,7,opt,name=remove_all_from_array,json=removeAllFromArray,proto3,oneof"`
}

func (*DocumentTransform_FieldTransform_SetToServerValue) isDocumentTransform_FieldTransform_TransformType() {
}

func (*DocumentTransform_FieldTransform_Increment) isDocumentTransform_FieldTransform_TransformType() {
}

func (*DocumentTransform_FieldTransform_Maximum) isDocumentTransform_FieldTransform_TransformType() {}

func (*DocumentTransform_FieldTransform_Minimum) isDocumentTransform_FieldTransform_TransformType() {}

func (*DocumentTransform_FieldTransform_AppendMissingElements) isDocumentTransform_FieldTransform_TransformType() {
}

func (*DocumentTransform_FieldTransform_RemoveAllFromArray) isDocumentTransform_FieldTransform_TransformType() {
}

func (m *DocumentTransform_FieldTransform) GetTransformType() isDocumentTransform_FieldTransform_TransformType {
	if m != nil {
		return m.TransformType
	}
	return nil
}

func (m *DocumentTransform_FieldTransform) GetSetToServerValue() DocumentTransform_FieldTransform_ServerValue {
	if x, ok := m.GetTransformType().(*DocumentTransform_FieldTransform_SetToServerValue); ok {
		return x.SetToServerValue
	}
	return DocumentTransform_FieldTransform_SERVER_VALUE_UNSPECIFIED
}

func (m *DocumentTransform_FieldTransform) GetIncrement() *Value {
	if x, ok := m.GetTransformType().(*DocumentTransform_FieldTransform_Increment); ok {
		return x.Increment
	}
	return nil
}

func (m *DocumentTransform_FieldTransform) GetMaximum() *Value {
	if x, ok := m.GetTransformType().(*DocumentTransform_FieldTransform_Maximum); ok {
		return x.Maximum
	}
	return nil
}

func (m *DocumentTransform_FieldTransform) GetMinimum() *Value {
	if x, ok := m.GetTransformType().(*DocumentTransform_FieldTransform_Minimum); ok {
		return x.Minimum
	}
	return nil
}

func (m *DocumentTransform_FieldTransform) GetAppendMissingElements() *ArrayValue {
	if x, ok := m.GetTransformType().(*DocumentTransform_FieldTransform_AppendMissingElements); ok {
		return x.AppendMissingElements
	}
	return nil
}

func (m *DocumentTransform_FieldTransform) GetRemoveAllFromArray() *ArrayValue {
	if x, ok := m.GetTransformType().(*DocumentTransform_FieldTransform_RemoveAllFromArray); ok {
		return x.RemoveAllFromArray
	}
	return nil
}

// XXX_OneofFuncs is for the internal use of the proto package.
func (*DocumentTransform_FieldTransform) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
	return _DocumentTransform_FieldTransform_OneofMarshaler, _DocumentTransform_FieldTransform_OneofUnmarshaler, _DocumentTransform_FieldTransform_OneofSizer, []interface{}{
		(*DocumentTransform_FieldTransform_SetToServerValue)(nil),
		(*DocumentTransform_FieldTransform_Increment)(nil),
		(*DocumentTransform_FieldTransform_Maximum)(nil),
		(*DocumentTransform_FieldTransform_Minimum)(nil),
		(*DocumentTransform_FieldTransform_AppendMissingElements)(nil),
		(*DocumentTransform_FieldTransform_RemoveAllFromArray)(nil),
	}
}

func _DocumentTransform_FieldTransform_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*DocumentTransform_FieldTransform)
	// transform_type
	switch x := m.TransformType.(type) {
	case *DocumentTransform_FieldTransform_SetToServerValue:
		b.EncodeVarint(2<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.SetToServerValue))
	case *DocumentTransform_FieldTransform_Increment:
		b.EncodeVarint(3<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Increment); err != nil {
			return err
		}
	case *DocumentTransform_FieldTransform_Maximum:
		b.EncodeVarint(4<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Maximum); err != nil {
			return err
		}
	case *DocumentTransform_FieldTransform_Minimum:
		b.EncodeVarint(5<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Minimum); err != nil {
			return err
		}
	case *DocumentTransform_FieldTransform_AppendMissingElements:
		b.EncodeVarint(6<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.AppendMissingElements); err != nil {
			return err
		}
	case *DocumentTransform_FieldTransform_RemoveAllFromArray:
		b.EncodeVarint(7<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.RemoveAllFromArray); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("DocumentTransform_FieldTransform.TransformType has unexpected type %T", x)
	}
	return nil
}

func _DocumentTransform_FieldTransform_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*DocumentTransform_FieldTransform)
	switch tag {
	case 2: // transform_type.set_to_server_value
		if wire != proto.WireVarint {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeVarint()
		m.TransformType = &DocumentTransform_FieldTransform_SetToServerValue{DocumentTransform_FieldTransform_ServerValue(x)}
		return true, err
	case 3: // transform_type.increment
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Value)
		err := b.DecodeMessage(msg)
		m.TransformType = &DocumentTransform_FieldTransform_Increment{msg}
		return true, err
	case 4: // transform_type.maximum
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Value)
		err := b.DecodeMessage(msg)
		m.TransformType = &DocumentTransform_FieldTransform_Maximum{msg}
		return true, err
	case 5: // transform_type.minimum
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Value)
		err := b.DecodeMessage(msg)
		m.TransformType = &DocumentTransform_FieldTransform_Minimum{msg}
		return true, err
	case 6: // transform_type.append_missing_elements
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(ArrayValue)
		err := b.DecodeMessage(msg)
		m.TransformType = &DocumentTransform_FieldTransform_AppendMissingElements{msg}
		return true, err
	case 7: // transform_type.remove_all_from_array
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(ArrayValue)
		err := b.DecodeMessage(msg)
		m.TransformType = &DocumentTransform_FieldTransform_RemoveAllFromArray{msg}
		return true, err
	default:
		return false, nil
	}
}

func _DocumentTransform_FieldTransform_OneofSizer(msg proto.Message) (n int) {
	m := msg.(*DocumentTransform_FieldTransform)
	// transform_type
	switch x := m.TransformType.(type) {
	case *DocumentTransform_FieldTransform_SetToServerValue:
		n += 1 // tag and wire
		n += proto.SizeVarint(uint64(x.SetToServerValue))
	case *DocumentTransform_FieldTransform_Increment:
		s := proto.Size(x.Increment)
		n += 1 // tag and wire
		n += proto.SizeVarint(uint64(s))
		n += s
	case *DocumentTransform_FieldTransform_Maximum:
		s := proto.Size(x.Maximum)
		n += 1 // tag and wire
		n += proto.SizeVarint(uint64(s))
		n += s
	case *DocumentTransform_FieldTransform_Minimum:
		s := proto.Size(x.Minimum)
		n += 1 // tag and wire
		n += proto.SizeVarint(uint64(s))
		n += s
	case *DocumentTransform_FieldTransform_AppendMissingElements:
		s := proto.Size(x.AppendMissingElements)
		n += 1 // tag and wire
		n += proto.SizeVarint(uint64(s))
		n += s
	case *DocumentTransform_FieldTransform_RemoveAllFromArray:
		s := proto.Size(x.RemoveAllFromArray)
		n += 1 // tag and wire
		n += proto.SizeVarint(uint64(s))
		n += s
	case nil:
	default:
		panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
	}
	return n
}

// The result of applying a write.
type WriteResult struct {
	// The last update time of the document after applying the write. Not set
	// after a `delete`.
	//
	// If the write did not actually change the document, this will be the
	// previous update_time.
	UpdateTime *timestamp.Timestamp `protobuf:"bytes,1,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty"`
	// The results of applying each
	// [DocumentTransform.FieldTransform][google.firestore.v1beta1.DocumentTransform.FieldTransform],
	// in the same order.
	TransformResults     []*Value `protobuf:"bytes,2,rep,name=transform_results,json=transformResults,proto3" json:"transform_results,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *WriteResult) Reset()         { *m = WriteResult{} }
func (m *WriteResult) String() string { return proto.CompactTextString(m) }
func (*WriteResult) ProtoMessage()    {}
func (*WriteResult) Descriptor() ([]byte, []int) {
	return fileDescriptor_write_f7b2ce45bbcfd263, []int{2}
}
func (m *WriteResult) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_WriteResult.Unmarshal(m, b)
}
func (m *WriteResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_WriteResult.Marshal(b, m, deterministic)
}
func (dst *WriteResult) XXX_Merge(src proto.Message) {
	xxx_messageInfo_WriteResult.Merge(dst, src)
}
func (m *WriteResult) XXX_Size() int {
	return xxx_messageInfo_WriteResult.Size(m)
}
func (m *WriteResult) XXX_DiscardUnknown() {
	xxx_messageInfo_WriteResult.DiscardUnknown(m)
}

var xxx_messageInfo_WriteResult proto.InternalMessageInfo

func (m *WriteResult) GetUpdateTime() *timestamp.Timestamp {
	if m != nil {
		return m.UpdateTime
	}
	return nil
}

func (m *WriteResult) GetTransformResults() []*Value {
	if m != nil {
		return m.TransformResults
	}
	return nil
}

// A [Document][google.firestore.v1beta1.Document] has changed.
//
// May be the result of multiple [writes][google.firestore.v1beta1.Write],
// including deletes, that ultimately resulted in a new value for the
// [Document][google.firestore.v1beta1.Document].
//
// Multiple [DocumentChange][google.firestore.v1beta1.DocumentChange] messages
// may be returned for the same logical change, if multiple targets are
// affected.
type DocumentChange struct {
	// The new state of the [Document][google.firestore.v1beta1.Document].
	//
	// If `mask` is set, contains only fields that were updated or added.
	Document *Document `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"`
	// A set of target IDs of targets that match this document.
	TargetIds []int32 `protobuf:"varint,5,rep,packed,name=target_ids,json=targetIds,proto3" json:"target_ids,omitempty"`
	// A set of target IDs for targets that no longer match this document.
	RemovedTargetIds     []int32  `protobuf:"varint,6,rep,packed,name=removed_target_ids,json=removedTargetIds,proto3" json:"removed_target_ids,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *DocumentChange) Reset()         { *m = DocumentChange{} }
func (m *DocumentChange) String() string { return proto.CompactTextString(m) }
func (*DocumentChange) ProtoMessage()    {}
func (*DocumentChange) Descriptor() ([]byte, []int) {
	return fileDescriptor_write_f7b2ce45bbcfd263, []int{3}
}
func (m *DocumentChange) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_DocumentChange.Unmarshal(m, b)
}
func (m *DocumentChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_DocumentChange.Marshal(b, m, deterministic)
}
func (dst *DocumentChange) XXX_Merge(src proto.Message) {
	xxx_messageInfo_DocumentChange.Merge(dst, src)
}
func (m *DocumentChange) XXX_Size() int {
	return xxx_messageInfo_DocumentChange.Size(m)
}
func (m *DocumentChange) XXX_DiscardUnknown() {
	xxx_messageInfo_DocumentChange.DiscardUnknown(m)
}

var xxx_messageInfo_DocumentChange proto.InternalMessageInfo

func (m *DocumentChange) GetDocument() *Document {
	if m != nil {
		return m.Document
	}
	return nil
}

func (m *DocumentChange) GetTargetIds() []int32 {
	if m != nil {
		return m.TargetIds
	}
	return nil
}

func (m *DocumentChange) GetRemovedTargetIds() []int32 {
	if m != nil {
		return m.RemovedTargetIds
	}
	return nil
}

// A [Document][google.firestore.v1beta1.Document] has been deleted.
//
// May be the result of multiple [writes][google.firestore.v1beta1.Write],
// including updates, the last of which deleted the
// [Document][google.firestore.v1beta1.Document].
//
// Multiple [DocumentDelete][google.firestore.v1beta1.DocumentDelete] messages
// may be returned for the same logical delete, if multiple targets are
// affected.
type DocumentDelete struct {
	// The resource name of the [Document][google.firestore.v1beta1.Document] that
	// was deleted.
	Document string `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"`
	// A set of target IDs for targets that previously matched this entity.
	RemovedTargetIds []int32 `protobuf:"varint,6,rep,packed,name=removed_target_ids,json=removedTargetIds,proto3" json:"removed_target_ids,omitempty"`
	// The read timestamp at which the delete was observed.
	//
	// Greater or equal to the `commit_time` of the delete.
	ReadTime             *timestamp.Timestamp `protobuf:"bytes,4,opt,name=read_time,json=readTime,proto3" json:"read_time,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

func (m *DocumentDelete) Reset()         { *m = DocumentDelete{} }
func (m *DocumentDelete) String() string { return proto.CompactTextString(m) }
func (*DocumentDelete) ProtoMessage()    {}
func (*DocumentDelete) Descriptor() ([]byte, []int) {
	return fileDescriptor_write_f7b2ce45bbcfd263, []int{4}
}
func (m *DocumentDelete) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_DocumentDelete.Unmarshal(m, b)
}
func (m *DocumentDelete) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_DocumentDelete.Marshal(b, m, deterministic)
}
func (dst *DocumentDelete) XXX_Merge(src proto.Message) {
	xxx_messageInfo_DocumentDelete.Merge(dst, src)
}
func (m *DocumentDelete) XXX_Size() int {
	return xxx_messageInfo_DocumentDelete.Size(m)
}
func (m *DocumentDelete) XXX_DiscardUnknown() {
	xxx_messageInfo_DocumentDelete.DiscardUnknown(m)
}

var xxx_messageInfo_DocumentDelete proto.InternalMessageInfo

func (m *DocumentDelete) GetDocument() string {
	if m != nil {
		return m.Document
	}
	return ""
}

func (m *DocumentDelete) GetRemovedTargetIds() []int32 {
	if m != nil {
		return m.RemovedTargetIds
	}
	return nil
}

func (m *DocumentDelete) GetReadTime() *timestamp.Timestamp {
	if m != nil {
		return m.ReadTime
	}
	return nil
}

// A [Document][google.firestore.v1beta1.Document] has been removed from the
// view of the targets.
//
// Sent if the document is no longer relevant to a target and is out of view.
// Can be sent instead of a DocumentDelete or a DocumentChange if the server
// can not send the new value of the document.
//
// Multiple [DocumentRemove][google.firestore.v1beta1.DocumentRemove] messages
// may be returned for the same logical write or delete, if multiple targets are
// affected.
type DocumentRemove struct {
	// The resource name of the [Document][google.firestore.v1beta1.Document] that
	// has gone out of view.
	Document string `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"`
	// A set of target IDs for targets that previously matched this document.
	RemovedTargetIds []int32 `protobuf:"varint,2,rep,packed,name=removed_target_ids,json=removedTargetIds,proto3" json:"removed_target_ids,omitempty"`
	// The read timestamp at which the remove was observed.
	//
	// Greater or equal to the `commit_time` of the change/delete/remove.
	ReadTime             *timestamp.Timestamp `protobuf:"bytes,4,opt,name=read_time,json=readTime,proto3" json:"read_time,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

func (m *DocumentRemove) Reset()         { *m = DocumentRemove{} }
func (m *DocumentRemove) String() string { return proto.CompactTextString(m) }
func (*DocumentRemove) ProtoMessage()    {}
func (*DocumentRemove) Descriptor() ([]byte, []int) {
	return fileDescriptor_write_f7b2ce45bbcfd263, []int{5}
}
func (m *DocumentRemove) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_DocumentRemove.Unmarshal(m, b)
}
func (m *DocumentRemove) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_DocumentRemove.Marshal(b, m, deterministic)
}
func (dst *DocumentRemove) XXX_Merge(src proto.Message) {
	xxx_messageInfo_DocumentRemove.Merge(dst, src)
}
func (m *DocumentRemove) XXX_Size() int {
	return xxx_messageInfo_DocumentRemove.Size(m)
}
func (m *DocumentRemove) XXX_DiscardUnknown() {
	xxx_messageInfo_DocumentRemove.DiscardUnknown(m)
}

var xxx_messageInfo_DocumentRemove proto.InternalMessageInfo

func (m *DocumentRemove) GetDocument() string {
	if m != nil {
		return m.Document
	}
	return ""
}

func (m *DocumentRemove) GetRemovedTargetIds() []int32 {
	if m != nil {
		return m.RemovedTargetIds
	}
	return nil
}

func (m *DocumentRemove) GetReadTime() *timestamp.Timestamp {
	if m != nil {
		return m.ReadTime
	}
	return nil
}

// A digest of all the documents that match a given target.
type ExistenceFilter struct {
	// The target ID to which this filter applies.
	TargetId int32 `protobuf:"varint,1,opt,name=target_id,json=targetId,proto3" json:"target_id,omitempty"`
	// The total count of documents that match
	// [target_id][google.firestore.v1beta1.ExistenceFilter.target_id].
	//
	// If different from the count of documents in the client that match, the
	// client must manually determine which documents no longer match the target.
	Count                int32    `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *ExistenceFilter) Reset()         { *m = ExistenceFilter{} }
func (m *ExistenceFilter) String() string { return proto.CompactTextString(m) }
func (*ExistenceFilter) ProtoMessage()    {}
func (*ExistenceFilter) Descriptor() ([]byte, []int) {
	return fileDescriptor_write_f7b2ce45bbcfd263, []int{6}
}
func (m *ExistenceFilter) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_ExistenceFilter.Unmarshal(m, b)
}
func (m *ExistenceFilter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_ExistenceFilter.Marshal(b, m, deterministic)
}
func (dst *ExistenceFilter) XXX_Merge(src proto.Message) {
	xxx_messageInfo_ExistenceFilter.Merge(dst, src)
}
func (m *ExistenceFilter) XXX_Size() int {
	return xxx_messageInfo_ExistenceFilter.Size(m)
}
func (m *ExistenceFilter) XXX_DiscardUnknown() {
	xxx_messageInfo_ExistenceFilter.DiscardUnknown(m)
}

var xxx_messageInfo_ExistenceFilter proto.InternalMessageInfo

func (m *ExistenceFilter) GetTargetId() int32 {
	if m != nil {
		return m.TargetId
	}
	return 0
}

func (m *ExistenceFilter) GetCount() int32 {
	if m != nil {
		return m.Count
	}
	return 0
}

func init() {
	proto.RegisterType((*Write)(nil), "google.firestore.v1beta1.Write")
	proto.RegisterType((*DocumentTransform)(nil), "google.firestore.v1beta1.DocumentTransform")
	proto.RegisterType((*DocumentTransform_FieldTransform)(nil), "google.firestore.v1beta1.DocumentTransform.FieldTransform")
	proto.RegisterType((*WriteResult)(nil), "google.firestore.v1beta1.WriteResult")
	proto.RegisterType((*DocumentChange)(nil), "google.firestore.v1beta1.DocumentChange")
	proto.RegisterType((*DocumentDelete)(nil), "google.firestore.v1beta1.DocumentDelete")
	proto.RegisterType((*DocumentRemove)(nil), "google.firestore.v1beta1.DocumentRemove")
	proto.RegisterType((*ExistenceFilter)(nil), "google.firestore.v1beta1.ExistenceFilter")
	proto.RegisterEnum("google.firestore.v1beta1.DocumentTransform_FieldTransform_ServerValue", DocumentTransform_FieldTransform_ServerValue_name, DocumentTransform_FieldTransform_ServerValue_value)
}

func init() {
	proto.RegisterFile("google/firestore/v1beta1/write.proto", fileDescriptor_write_f7b2ce45bbcfd263)
}

var fileDescriptor_write_f7b2ce45bbcfd263 = []byte{
	// 866 bytes of a gzipped FileDescriptorProto
	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xdd, 0x6e, 0xe3, 0x44,
	0x14, 0x6e, 0xd2, 0x26, 0xdb, 0x9c, 0xa0, 0xd6, 0x3b, 0xb0, 0xc2, 0x0a, 0x5d, 0xb6, 0x8a, 0x16,
	0xa8, 0x04, 0x72, 0xd4, 0x72, 0x81, 0xc4, 0xf2, 0xa3, 0xa6, 0x75, 0xda, 0x8a, 0x2d, 0xca, 0x3a,
	0x69, 0x10, 0xa8, 0xc2, 0x9a, 0xc6, 0x27, 0xae, 0xb5, 0xf6, 0x8c, 0x35, 0x33, 0xee, 0xee, 0xbe,
	0x01, 0xf7, 0xdc, 0x70, 0xc3, 0x0d, 0x97, 0x3c, 0x01, 0xcf, 0xc0, 0x3d, 0xcf, 0xc1, 0x2b, 0x20,
	0xcf, 0xd8, 0x6e, 0xca, 0x2a, 0xa4, 0x5d, 0x71, 0x97, 0x33, 0xf3, 0x7d, 0xdf, 0xf9, 0x3c, 0xdf,
	0xcc, 0x09, 0x3c, 0x0e, 0x39, 0x0f, 0x63, 0xec, 0xcd, 0x22, 0x81, 0x52, 0x71, 0x81, 0xbd, 0xab,
	0xdd, 0x0b, 0x54, 0x74, 0xb7, 0xf7, 0x42, 0x44, 0x0a, 0x9d, 0x54, 0x70, 0xc5, 0x89, 0x6d, 0x50,
	0x4e, 0x85, 0x72, 0x0a, 0x54, 0x67, 0xab, 0xe0, 0xd3, 0x34, 0xea, 0x51, 0xc6, 0xb8, 0xa2, 0x2a,
	0xe2, 0x4c, 0x1a, 0x5e, 0xe7, 0x83, 0x85, 0xea, 0x53, 0x9e, 0x24, 0x9c, 0x15, 0xb0, 0x8f, 0x16,
	0xc2, 0x02, 0x3e, 0xcd, 0x12, 0x64, 0xaa, 0x00, 0x3e, 0x2a, 0x80, 0xba, 0xba, 0xc8, 0x66, 0x3d,
	0x15, 0x25, 0x28, 0x15, 0x4d, 0x52, 0x03, 0xe8, 0xfe, 0x55, 0x87, 0xc6, 0x77, 0xb9, 0x71, 0xf2,
	0x05, 0x34, 0xb3, 0x34, 0xa0, 0x0a, 0xed, 0xda, 0x76, 0x6d, 0xa7, 0xbd, 0xd7, 0x75, 0x16, 0x7d,
	0x83, 0x73, 0x58, 0x34, 0x39, 0x5e, 0xf1, 0x0a, 0x0e, 0xb1, 0xa1, 0x19, 0x60, 0x8c, 0x0a, 0xed,
	0xfa, 0x76, 0x6d, 0xa7, 0x95, 0xef, 0x98, 0x9a, 0x7c, 0x03, 0x2d, 0x25, 0x28, 0x93, 0x33, 0x2e,
	0x12, 0xbb, 0xa9, 0xa5, 0x3f, 0x5e, 0x2e, 0x3d, 0x2e, 0x29, 0xc7, 0x2b, 0xde, 0x35, 0x9f, 0x1c,
	0x41, 0xdb, 0x34, 0xf4, 0x13, 0x2a, 0x9f, 0xdb, 0xab, 0x5a, 0xee, 0xc3, 0xe5, 0x72, 0xa7, 0x54,
	0x3e, 0xf7, 0xc0, 0x50, 0xf3, 0xdf, 0xe4, 0x19, 0x58, 0xd3, 0x4c, 0x08, 0x64, 0xca, 0x2f, 0x8f,
	0xcc, 0x5e, 0x5b, 0xa6, 0x36, 0x14, 0x38, 0xe5, 0x2c, 0x88, 0xf2, 0xc4, 0xbc, 0xcd, 0x82, 0x5f,
	0xb6, 0xe8, 0xb7, 0xa1, 0xc5, 0x53, 0x14, 0x3a, 0xcf, 0xee, 0x4f, 0x4d, 0xb8, 0xff, 0xda, 0xb7,
	0x90, 0x0e, 0xac, 0x57, 0xdd, 0xf2, 0x53, 0x6e, 0x79, 0x55, 0x4d, 0x10, 0xac, 0x59, 0x84, 0x71,
	0xe0, 0x57, 0x5f, 0x2b, 0xed, 0xfa, 0xf6, 0xea, 0x4e, 0x7b, 0xef, 0xf3, 0x3b, 0x1c, 0x97, 0x33,
	0xc8, 0x35, 0xaa, 0xd2, 0xdb, 0x9c, 0xdd, 0xa8, 0x65, 0xe7, 0xef, 0x35, 0xd8, 0xb8, 0x89, 0x21,
	0x0f, 0x01, 0x4c, 0xe7, 0x94, 0xaa, 0xcb, 0xc2, 0x57, 0x4b, 0xaf, 0x0c, 0xa9, 0xba, 0x24, 0x2f,
	0xe0, 0x6d, 0x89, 0xca, 0x57, 0xdc, 0x97, 0x28, 0xae, 0x50, 0xf8, 0x57, 0x34, 0xce, 0x4c, 0xce,
	0x1b, 0x7b, 0x83, 0x37, 0xf7, 0xe6, 0x8c, 0xb4, 0xdc, 0x24, 0x57, 0x3b, 0x5e, 0xf1, 0x2c, 0x89,
	0x6a, 0xcc, 0xe7, 0xd6, 0xc8, 0xd7, 0xd0, 0x8a, 0xd8, 0x54, 0xa0, 0x3e, 0x2e, 0x13, 0xf5, 0xa3,
	0xc5, 0xed, 0x4a, 0x9d, 0x6b, 0x0e, 0x79, 0x02, 0xf7, 0x12, 0xfa, 0x32, 0x4a, 0xb2, 0xa4, 0xc8,
	0xf6, 0x16, 0xf4, 0x92, 0xa1, 0xc9, 0x11, 0xd3, 0xe4, 0xc6, 0xed, 0xc9, 0x86, 0x41, 0x7e, 0x84,
	0x77, 0x69, 0x9a, 0x22, 0x0b, 0xfc, 0x24, 0x92, 0x32, 0x62, 0xa1, 0x8f, 0xb1, 0xf6, 0x24, 0x8b,
	0x27, 0xf0, 0x78, 0xb1, 0xd8, 0xbe, 0x10, 0xf4, 0x55, 0xa9, 0xf8, 0xc0, 0xc8, 0x9c, 0x1a, 0x15,
	0xb7, 0x10, 0x21, 0xdf, 0xc3, 0x03, 0x81, 0x09, 0xbf, 0x42, 0x9f, 0xc6, 0xb1, 0x3f, 0x13, 0x3c,
	0xf1, 0x69, 0x4e, 0xb3, 0xef, 0xdd, 0x49, 0x9d, 0x18, 0x91, 0xfd, 0x38, 0x1e, 0x08, 0x9e, 0xe8,
	0xad, 0xee, 0x97, 0xd0, 0x9e, 0x0f, 0x61, 0x0b, 0xec, 0x91, 0xeb, 0x4d, 0x5c, 0xcf, 0x9f, 0xec,
	0x3f, 0x3d, 0x73, 0xfd, 0xb3, 0x6f, 0x47, 0x43, 0xf7, 0xe0, 0x64, 0x70, 0xe2, 0x1e, 0x5a, 0x2b,
	0xc4, 0x82, 0xb7, 0x3c, 0xf7, 0xd9, 0x99, 0x3b, 0x1a, 0xfb, 0xe3, 0x93, 0x53, 0xd7, 0xaa, 0xf5,
	0x2d, 0xd8, 0xa8, 0x2e, 0xb0, 0xaf, 0x5e, 0xa5, 0xd8, 0xfd, 0xa5, 0x06, 0x6d, 0x3d, 0x62, 0x3c,
	0x94, 0x59, 0x9c, 0xa7, 0x52, 0xbe, 0xe1, 0x7c, 0x18, 0x15, 0xd3, 0xa6, 0x53, 0x3a, 0x2e, 0x27,
	0x95, 0x33, 0x2e, 0x27, 0x55, 0xf9, 0x6e, 0xf3, 0x05, 0xf2, 0x14, 0xee, 0x5f, 0xcb, 0x0b, 0x2d,
	0x58, 0x3e, 0x93, 0x65, 0xf9, 0x78, 0x56, 0xc5, 0x34, 0x4e, 0x64, 0xf7, 0xd7, 0x1a, 0x6c, 0x94,
	0xd7, 0xf4, 0xe0, 0x92, 0xb2, 0x10, 0xc9, 0x57, 0xff, 0x7a, 0xa2, 0xb7, 0x1a, 0x84, 0x73, 0xcf,
	0xf8, 0x21, 0x80, 0xa2, 0x22, 0x44, 0xe5, 0x47, 0x81, 0xb4, 0x1b, 0xdb, 0xab, 0x3b, 0x0d, 0xaf,
	0x65, 0x56, 0x4e, 0x02, 0x49, 0x3e, 0x81, 0xe2, 0xcc, 0x03, 0x7f, 0x0e, 0xd6, 0xd4, 0x30, 0xab,
	0xd8, 0x19, 0x97, 0xe8, 0xee, 0xcf, 0x73, 0xfe, 0x0e, 0xcd, 0x38, 0xfd, 0xaf, 0x11, 0x72, 0x27,
	0x71, 0xf2, 0x19, 0xb4, 0x04, 0xd2, 0xc0, 0xa4, 0xb0, 0xb6, 0x34, 0x85, 0xf5, 0x1c, 0x9c, 0x97,
	0x37, 0x5c, 0x79, 0x5a, 0xf5, 0x0d, 0x5c, 0xd5, 0xff, 0x6f, 0x57, 0x87, 0xb0, 0xe9, 0xbe, 0x8c,
	0xa4, 0x42, 0x36, 0xc5, 0x41, 0x14, 0x2b, 0x14, 0xe4, 0x3d, 0x68, 0x55, 0x1d, 0xb5, 0xad, 0x86,
	0xb7, 0x5e, 0x46, 0x41, 0xde, 0x81, 0xc6, 0x94, 0x67, 0x4c, 0xe9, 0x41, 0xd6, 0xf0, 0x4c, 0xd1,
	0xff, 0xa3, 0x06, 0x5b, 0x53, 0x9e, 0x2c, 0x8c, 0xbc, 0x0f, 0xfa, 0x2a, 0x0f, 0x73, 0x27, 0xc3,
	0xda, 0x0f, 0xfb, 0x05, 0x2e, 0xe4, 0x31, 0x65, 0xa1, 0xc3, 0x45, 0xd8, 0x0b, 0x91, 0x69, 0x9f,
	0x3d, 0xb3, 0x45, 0xd3, 0x48, 0xbe, 0xfe, 0x3f, 0xfd, 0xa4, 0x5a, 0xf9, 0xad, 0xbe, 0x76, 0x74,
	0x30, 0x18, 0xfd, 0x5e, 0x7f, 0xff, 0xc8, 0x48, 0x1d, 0xc4, 0x3c, 0x0b, 0x9c, 0x41, 0xd5, 0x78,
	0xb2, 0xdb, 0xcf, 0x19, 0x7f, 0x96, 0x80, 0x73, 0x0d, 0x38, 0xaf, 0x00, 0xe7, 0x13, 0x23, 0x79,
	0xd1, 0xd4, 0x6d, 0x3f, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0x98, 0x5d, 0x9d, 0xb3, 0xa2, 0x08,
	0x00, 0x00,
}


text:
<script src="modules/rammy.js"></script>
<script src="modules/settings.js"></script>

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Web;
using Firehose.Web.Infrastructure;
namespace Firehose.Web.Authors
{
    public class ToreGroneng : IAmACommunityMember
    {
        public string FirstName => "Tore";
        public string LastName => "Groneng";
        public string ShortBioOrTagLine => "Focus on Powershell, Azure, Cloud, System Center and Powershell DSC. Automate everything.";
        public string StateOrRegion => "Bergen, Norway";
        public string EmailAddress => "tore.groneng@gmail.com";
        public string TwitterHandle => "ToreGroneng";
        public string GitHubHandle => "torgro";
        public string GravatarHash => "5179a5eb394ca18bf14daa4e3987989b";
        public GeoPosition Position => new GeoPosition(60.4698789, 5.3307659);

        public Uri WebSite => new Uri("https://asaconsultant.blogspot.no");
        public IEnumerable<Uri> FeedUris { get { yield return new Uri("https://asaconsultant.blogspot.com/feeds/posts/default/-/Powershell"); } }
        public string FeedLanguageCode => "en";
    }
}


text:
package mungers

import (
	"encoding/json"
	"fmt"
	"net/http"
	"runtime"
	"testing"

	github_util "k8s.io/test-infra/mungegithub/github"
	github_test "k8s.io/test-infra/mungegithub/github/testing"

	"github.com/golang/glog"
	"github.com/google/go-github/github"
)

var (
	_ = fmt.Printf
	_ = glog.Errorf
)

func docsProposalIssue(testBotName string) *github.Issue {
	return github_test.Issue(testBotName, 1, []string{claYesLabel, "kind/design"}, true)
}

// Commit returns a filled out github.Commit which happened at time.Unix(t, 0)
func commitFiles(path []string) []*github.CommitFile {
	files := []*github.CommitFile{}
	for _, p := range path {
		f := &github.CommitFile{
			Filename: stringPtr(p),
		}
		files = append(files, f)
	}
	return files
}

func BotAddedDesign(testBotName string) []*github.IssueEvent {
	return github_test.Events([]github_test.LabelTime{
		{User: testBotName, Label: "kind/design", Time: 9},
		{User: "bob", Label: "kind/design", Time: 8},
	})
}

func OtherAddedDesign(testBotName string) []*github.IssueEvent {
	return github_test.Events([]github_test.LabelTime{
		{User: testBotName, Label: "kind/design", Time: 8},
		{User: "bob", Label: "kind/design", Time: 9},
	})
}

func TestPathLabelMunge(t *testing.T) {
	const testBotName = "dummy"
	runtime.GOMAXPROCS(runtime.NumCPU())

	tests := []struct {
		files       []*github.CommitFile
		events      []*github.IssueEvent
		mustHave    []string
		mustNotHave []string
	}{
		{
			files:       commitFiles([]string{"docs/proposals"}),
			events:      BotAddedDesign(testBotName),
			mustHave:    []string{"kind/design"},
			mustNotHave: []string{"kind/api-change", "kind/new-api"},
		},
		{
			files:       commitFiles([]string{"docs/my/proposals"}),
			events:      BotAddedDesign(testBotName),
			mustHave:    []string{},
			mustNotHave: []string{"kind/design", "kind/api-change", "kind/new-api"},
		},
		{
			files:       commitFiles([]string{"pkg/api/types.go"}),
			events:      BotAddedDesign(testBotName),
			mustHave:    []string{"kind/api-change"},
			mustNotHave: []string{"kind/design", "kind/new-api"},
		},
		{
			files:       commitFiles([]string{"pkg/api/v1/types.go"}),
			events:      BotAddedDesign(testBotName),
			mustHave:    []string{"kind/api-change"},
			mustNotHave: []string{"kind/design", "kind/new-api"},
		},
		{
			files:       commitFiles([]string{"pkg/api/v1/duh/types.go"}),
			events:      BotAddedDesign(testBotName),
			mustHave:    []string{},
			mustNotHave: []string{"kind/design", "kind/api-change", "kind/new-api"},
		},
		{
			files:       commitFiles([]string{"pkg/apis/experimental/register.go"}),
			events:      BotAddedDesign(testBotName),
			mustHave:    []string{"kind/new-api"},
			mustNotHave: []string{"kind/api-change", "kind/design"},
		},
		{
			files:       commitFiles([]string{"pkg/apis/experimental/v1beta1/register.go"}),
			events:      BotAddedDesign(testBotName),
			mustHave:    []string{"kind/new-api"},
			mustNotHave: []string{"kind/api-change", "kind/design"},
		},
		{
			files:       commitFiles([]string{"pkg/apis/experiments/v1beta1/duh/register.go"}),
			events:      BotAddedDesign(testBotName),
			mustHave:    []string{},
			mustNotHave: []string{"kind/design", "kind/api-change", "kind/new-api"},
		},
		{
			files:       commitFiles([]string{"README"}),
			events:      OtherAddedDesign(testBotName),
			mustHave:    []string{"kind/design"},
			mustNotHave: []string{"kind/api-change", "kind/new-api"},
		},
	}
	for testNum, test := range tests {
		client, server, mux := github_test.InitServer(t, docsProposalIssue(testBotName), ValidPR(), test.events, nil, nil, nil, test.files)
		mux.HandleFunc("/repos/o/r/issues/1/labels/kind/design", func(w http.ResponseWriter, r *http.Request) {
			w.WriteHeader(http.StatusOK)
			w.Write([]byte{})
		})
		mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) {
			w.WriteHeader(http.StatusOK)
			out := []github.Label{{}}
			data, err := json.Marshal(out)
			if err != nil {
				t.Errorf("Unexpected error: %v", err)
			}
			w.Write(data)

		})

		config := &github_util.Config{
			Org:     "o",
			Project: "r",
		}
		config.SetClient(client)
		config.BotName = testBotName

		p := PathLabelMunger{pathLabelFile: "../path-label.txt"}
		err := p.Initialize(config, nil)
		if err != nil {
			t.Fatalf("%v", err)
		}

		obj, err := config.GetObject(1)
		if err != nil {
			t.Fatalf("%v", err)
		}

		p.Munge(obj)

		for _, l := range test.mustHave {
			if !obj.HasLabel(l) {
				t.Errorf("%d: Did not find label %q, labels: %v", testNum, l, obj.Issue.Labels)
			}
		}
		for _, l := range test.mustNotHave {
			if obj.HasLabel(l) {
				t.Errorf("%d: Found label %q and should not have, labels: %v", testNum, l, obj.Issue.Labels)
			}
		}
		server.Close()
	}
}


text:
<!DOCTYPE html>

hello selected world


text:
<?xml version="1.0" encoding="UTF-8"?><project-private xmlns="http://www.netbeans.org/ns/project-private/1">
    <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
    <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
        <group>
            <file>file:/C:/Work/Mobile/agrodadosmobile/AgroDados/package.json</file>
            <file>file:/C:/Work/Mobile/agrodadosmobile/AgroDados/src/app/app.html</file>
            <file>file:/C:/Work/Mobile/agrodadosmobile/AgroDados/src/app/app.component.ts</file>
            <file>file:/C:/Work/Mobile/agrodadosmobile/AgroDados/src/app/app.module.ts</file>
        </group>
    </open-files>
</project-private>


text:
package org.apache.hadoop.hive.ql.exec.vector.expressions;

import java.util.List;

import org.apache.hadoop.hive.ql.exec.vector.ColumnVector;
import org.apache.hadoop.hive.ql.exec.vector.VectorizationContext;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;

/**
 * Interface used for both filter and non-filter versions of IN to simplify
 * VectorizationContext code.
 */
public interface IStructInExpr {
  void setScratchBytesColumn(int scratchBytesColumn);
  void setStructColumnExprs(VectorizationContext vContext, List<ExprNodeDesc> structColumnExprs,
      ColumnVector.Type[] fieldVectorColumnTypes) throws HiveException;
}


text:
from __future__ import absolute_import

from mock import Mock

from sentry.api.bases.project import ProjectPermission
from sentry.models import ApiKey
from sentry.testutils import TestCase

class ProjectPermissionBase(TestCase):
    def setUp(self):
        self.org = self.create_organization()
        self.team = self.create_team(organization=self.org)
        self.project = self.create_project(organization=self.org)
        super(ProjectPermissionBase, self).setUp()

    def has_object_perm(self, method, obj, auth=None, user=None, is_superuser=None):
        perm = ProjectPermission()
        request = Mock()
        request.auth = auth
        request.user = user
        request.method = method
        request.is_superuser = lambda: is_superuser if is_superuser is not None else user.is_superuser
        return (
            perm.has_permission(request, None) and
            perm.has_object_permission(request, None, obj)
        )

class ProjectPermissionTest(ProjectPermissionBase):
    def test_regular_user(self):
        user = self.create_user(is_superuser=False)
        assert not self.has_object_perm('GET', self.project, user=user)

    def test_superuser(self):
        user = self.create_user(is_superuser=True)
        assert self.has_object_perm('GET', self.project, user=user)

    def test_member_for_project_read(self):
        user = self.create_user(is_superuser=False)
        self.create_member(
            user=user,
            organization=self.org,
            role='member',
            teams=[self.team],
        )
        assert self.has_object_perm('GET', self.project, user=user)

    def test_member_for_project_write(self):
        user = self.create_user(is_superuser=False)
        self.create_member(
            user=user,
            organization=self.org,
            role='member',
            teams=[self.team],
        )
        assert not self.has_object_perm('POST', self.project, user=user)

    def test_member_for_project_delete(self):
        user = self.create_user(is_superuser=False)
        self.create_member(
            user=user,
            organization=self.org,
            role='member',
            teams=[self.team],
        )
        assert not self.has_object_perm('DELETE', self.project, user=user)

    def test_member_with_team_access(self):
        user = self.create_user(is_superuser=False)
        self.create_member(
            user=user,
            organization=self.org,
            role='member',
            teams=[self.team]
        )
        assert self.has_object_perm('GET', self.project, user=user)

    def test_api_key_with_org_access(self):
        key = ApiKey.objects.create(
            organization=self.org,
            scopes=getattr(ApiKey.scopes, 'project:read'),
        )
        assert self.has_object_perm('GET', self.project, auth=key)

    def test_api_key_without_org_access(self):
        key = ApiKey.objects.create(
            organization=self.create_organization(),
            scopes=getattr(ApiKey.scopes, 'project:read'),
        )
        assert not self.has_object_perm('GET', self.project, auth=key)

    def test_api_key_without_access(self):
        key = ApiKey.objects.create(
            organization=self.org,
            scopes=0,
        )
        assert not self.has_object_perm('GET', self.project, auth=key)

    def test_api_key_with_wrong_access(self):
        key = ApiKey.objects.create(
            organization=self.org,
            scopes=getattr(ApiKey.scopes, 'team:read'),
        )
        assert not self.has_object_perm('GET', self.project, auth=key)

    def test_api_key_with_wrong_access_for_method(self):
        key = ApiKey.objects.create(
            organization=self.org,
            scopes=getattr(ApiKey.scopes, 'project:read'),
        )
        assert not self.has_object_perm('PUT', self.project, auth=key)


text:
{% filter markdown %}
Dear {{user.username}},

{{g.user.username}} has updated the task {{task.title}} with the following:

{{post.post}}

Sincerely,

The Kinkstruction Admin
{% endfilter %}


text:
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/autofill_assistant/browser/service/service_request_sender_impl.h"

#include <memory>

#include "base/memory/scoped_refptr.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill_assistant/browser/features.h"
#include "components/autofill_assistant/browser/metrics.h"
#include "components/autofill_assistant/browser/service.pb.h"
#include "components/autofill_assistant/browser/service/access_token_fetcher.h"
#include "components/autofill_assistant/browser/service/mock_access_token_fetcher.h"
#include "components/autofill_assistant/browser/service/mock_cup.h"
#include "components/autofill_assistant/browser/service/mock_simple_url_loader_factory.h"
#include "components/autofill_assistant/browser/service/mock_url_loader.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace autofill_assistant {

using ::base::test::RunOnceCallback;
using ::network::URLLoaderCompletionStatus;
using ::testing::_;
using ::testing::Field;
using ::testing::Matcher;
using ::testing::NiceMock;
using ::testing::Return;
using ::testing::ReturnRef;

namespace {

std::unique_ptr<::network::mojom::URLResponseHead> CreateResponseInfo(
    int status_code,
    const std::string& status) {
  auto response = std::make_unique<::network::mojom::URLResponseHead>();
  response->headers =
      base::MakeRefCounted<::net::HttpResponseHeaders>(base::StrCat(
          {"HTTP/1.1 ", base::NumberToString(status_code), " ", status}));
  return response;
}

class ServiceRequestSenderImplTest : public testing::Test {
 public:
  ServiceRequestSenderImplTest() = default;
  ~ServiceRequestSenderImplTest() override = default;

 protected:
  base::test::ScopedFeatureList scoped_feature_list_;
  base::MockCallback<base::OnceCallback<
      void(int, const std::string&, const ServiceRequestSender::ResponseInfo&)>>
      mock_response_callback_;
  // Note: |task_environment_| must be created before |context_|, else creation
  // of |context_| will fail (see content/public/test/test_browser_context.cc).
  content::BrowserTaskEnvironment task_environment_;
  content::TestBrowserContext context_;
  NiceMock<MockAccessTokenFetcher> mock_access_token_fetcher_;

  absl::optional<URLLoaderCompletionStatus> completion_status_ = absl::nullopt;

  void InitCupFeatures(bool enableSigning, bool enableVerifying) {
    std::vector<base::Feature> enabled_features;
    std::vector<base::Feature> disabled_features;

    if (enableSigning) {
      enabled_features.push_back(autofill_assistant::features::
                                     kAutofillAssistantSignGetActionsRequests);
    } else {
      disabled_features.push_back(autofill_assistant::features::
                                      kAutofillAssistantSignGetActionsRequests);
    }

    if (enableVerifying) {
      enabled_features.push_back(
          autofill_assistant::features::
              kAutofillAssistantVerifyGetActionsResponses);
    } else {
      disabled_features.push_back(
          autofill_assistant::features::
              kAutofillAssistantVerifyGetActionsResponses);
    }

    scoped_feature_list_.Reset();
    scoped_feature_list_.InitWithFeatures(enabled_features, disabled_features);
  }
};

TEST_F(ServiceRequestSenderImplTest, SendUnauthenticatedRequest) {
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        EXPECT_FALSE(resource_request->headers.HasHeader("Authorization"));
        EXPECT_EQ(resource_request->url,
                  GURL("https://www.example.com/?key=fake_api_key"));
        return std::move(loader);
      });
  EXPECT_CALL(*loader,
              AttachStringForUpload(std::string("request"),
                                    std::string("application/x-protobuffer")));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));

  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ nullptr, std::move(cup_factory),
      std::move(loader_factory), std::string("fake_api_key")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::API_KEY, mock_response_callback_.Get(),
      RpcType::GET_TRIGGER_SCRIPTS);
}

TEST_F(ServiceRequestSenderImplTest, SendAuthenticatedRequest) {
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        std::string authorization;
        EXPECT_TRUE(resource_request->headers.GetHeader("Authorization",
                                                        &authorization));
        EXPECT_EQ(authorization, "Bearer access_token");
        EXPECT_EQ(resource_request->url, GURL("https://www.example.com"));
        return std::move(loader);
      });
  EXPECT_CALL(*loader,
              AttachStringForUpload(std::string("request"),
                                    std::string("application/x-protobuffer")));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(mock_access_token_fetcher_, OnFetchAccessToken)
      .WillOnce(RunOnceCallback<0>(true, "access_token"));
  EXPECT_CALL(mock_access_token_fetcher_, InvalidateAccessToken).Times(0);

  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ &mock_access_token_fetcher_,
      std::move(cup_factory), std::move(loader_factory),
      /* api_key = */ std::string("")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::OAUTH_WITH_API_KEY_FALLBACK,
      mock_response_callback_.Get(), autofill_assistant::RpcType::GET_ACTIONS);
}

TEST_F(ServiceRequestSenderImplTest, ForceAuthenticatedRequest) {
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        std::string authorization;
        EXPECT_TRUE(resource_request->headers.GetHeader("Authorization",
                                                        &authorization));
        EXPECT_EQ(authorization, "Bearer access_token");
        EXPECT_EQ(resource_request->url, GURL("https://www.example.com"));
        return std::move(loader);
      });
  EXPECT_CALL(*loader,
              SetRetryOptions(
                  2, network::SimpleURLLoader::RETRY_ON_NETWORK_CHANGE |
                         network::SimpleURLLoader::RETRY_ON_NAME_NOT_RESOLVED |
                         network::SimpleURLLoader::RETRY_ON_5XX));
  EXPECT_CALL(*loader,
              AttachStringForUpload(std::string("request"),
                                    std::string("application/x-protobuffer")));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(mock_access_token_fetcher_, OnFetchAccessToken)
      .WillOnce(RunOnceCallback<0>(true, "access_token"));
  EXPECT_CALL(mock_access_token_fetcher_, InvalidateAccessToken).Times(0);

  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ &mock_access_token_fetcher_,
      std::move(cup_factory), std::move(loader_factory),
      /* api_key = */ std::string("fake_api_key")};
  request_sender.SendRequest(GURL("https://www.example.com"),
                             std::string("request"),
                             ServiceRequestSender::AuthMode::OAUTH_STRICT,
                             mock_response_callback_.Get(),
                             autofill_assistant::RpcType::GET_USER_DATA);
}

TEST_F(ServiceRequestSenderImplTest,
       AuthRequestFallsBackToApiKeyOnEmptyAccessToken) {
  EXPECT_CALL(mock_access_token_fetcher_, OnFetchAccessToken)
      .WillOnce(RunOnceCallback<0>(true, /*access_token = */ ""));

  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        EXPECT_FALSE(resource_request->headers.HasHeader("Authorization"));
        EXPECT_EQ(resource_request->url,
                  GURL("https://www.example.com/?key=fake_api_key"));
        return std::move(loader);
      });
  EXPECT_CALL(*loader,
              AttachStringForUpload(std::string("request"),
                                    std::string("application/x-protobuffer")));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));

  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ &mock_access_token_fetcher_,
      std::move(cup_factory), std::move(loader_factory),
      /* api_key = */ std::string("fake_api_key")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::OAUTH_WITH_API_KEY_FALLBACK,
      mock_response_callback_.Get(), autofill_assistant::RpcType::GET_ACTIONS);
}

TEST_F(ServiceRequestSenderImplTest,
       AuthRequestFallsBackToApiKeyIfFetchingAccessTokenFails) {
  EXPECT_CALL(mock_access_token_fetcher_, OnFetchAccessToken)
      .WillOnce(
          RunOnceCallback<0>(/*success = */ false, /*access_token = */ ""));

  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        EXPECT_FALSE(resource_request->headers.HasHeader("Authorization"));
        EXPECT_EQ(resource_request->url,
                  GURL("https://www.example.com/?key=fake_api_key"));
        return std::move(loader);
      });
  EXPECT_CALL(*loader,
              AttachStringForUpload(std::string("request"),
                                    std::string("application/x-protobuffer")));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));

  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ &mock_access_token_fetcher_,
      std::move(cup_factory), std::move(loader_factory),
      /* api_key = */ std::string("fake_api_key")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::OAUTH_WITH_API_KEY_FALLBACK,
      mock_response_callback_.Get(), autofill_assistant::RpcType::GET_ACTIONS);
}

TEST_F(ServiceRequestSenderImplTest,
       AuthRequestFailsOnFetchErrorForForcedAuthentication) {
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  EXPECT_CALL(*loader_factory, OnCreateLoader).Times(0);
  EXPECT_CALL(*loader, SetRetryOptions).Times(0);
  EXPECT_CALL(*loader, AttachStringForUpload(Matcher<const std::string&>(_),
                                             Matcher<const std::string&>(_)))
      .Times(0);
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .Times(0);
  EXPECT_CALL(*loader, ResponseInfo).Times(0);
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(mock_access_token_fetcher_, OnFetchAccessToken)
      .WillOnce(RunOnceCallback<0>(false, /*access_token = */ ""));
  EXPECT_CALL(mock_access_token_fetcher_, InvalidateAccessToken).Times(0);

  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_UNAUTHORIZED, "", _));
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ &mock_access_token_fetcher_,
      std::move(cup_factory), std::move(loader_factory),
      /* api_key = */ std::string("fake_api_key")};
  request_sender.SendRequest(GURL("https://www.example.com"),
                             std::string("request"),
                             ServiceRequestSender::AuthMode::OAUTH_STRICT,
                             mock_response_callback_.Get(),
                             autofill_assistant::RpcType::GET_USER_DATA);
}

TEST_F(ServiceRequestSenderImplTest, SignsGetActionsRequestWhenFeatureEnabled) {
  InitCupFeatures(true, false);
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto cup = std::make_unique<NiceMock<autofill_assistant::cup::MockCUP>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        EXPECT_FALSE(resource_request->headers.HasHeader("Authorization"));
        EXPECT_EQ(resource_request->url,
                  GURL("https://www.example.com/?key=fake_api_key"));
        return std::move(loader);
      });
  EXPECT_CALL(*loader,
              AttachStringForUpload(std::string("signed_request"),
                                    std::string("application/x-protobuffer")));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));

  EXPECT_CALL(*cup_factory,
              CreateInstance(autofill_assistant::RpcType::GET_ACTIONS))
      .WillOnce([&]() { return std::move(cup); });
  EXPECT_CALL(*cup, PackAndSignRequest("request")).WillOnce([&]() {
    return "signed_request";
  });
  EXPECT_CALL(*cup, UnpackResponse).Times(0);
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ nullptr, std::move(cup_factory),
      std::move(loader_factory), std::string("fake_api_key")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::API_KEY, mock_response_callback_.Get(),
      RpcType::GET_ACTIONS);
}

TEST_F(ServiceRequestSenderImplTest, ValidatesGetActionsResponsesWhenEnabled) {
  InitCupFeatures(true, true);
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto cup = std::make_unique<NiceMock<autofill_assistant::cup::MockCUP>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        EXPECT_FALSE(resource_request->headers.HasHeader("Authorization"));
        EXPECT_EQ(resource_request->url,
                  GURL("https://www.example.com/?key=fake_api_key"));
        return std::move(loader);
      });
  EXPECT_CALL(*loader,
              AttachStringForUpload(std::string("signed_request"),
                                    std::string("application/x-protobuffer")));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(
          RunOnceCallback<1>(std::make_unique<std::string>("packed_response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));

  EXPECT_CALL(*cup_factory,
              CreateInstance(autofill_assistant::RpcType::GET_ACTIONS))
      .WillOnce([&]() { return std::move(cup); });
  EXPECT_CALL(*cup, PackAndSignRequest("request")).WillOnce([&]() {
    return "signed_request";
  });
  EXPECT_CALL(*cup, UnpackResponse("packed_response")).WillOnce([&]() {
    return "response";
  });
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ nullptr, std::move(cup_factory),
      std::move(loader_factory), std::string("fake_api_key")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::API_KEY, mock_response_callback_.Get(),
      autofill_assistant::RpcType::GET_ACTIONS);
}

TEST_F(ServiceRequestSenderImplTest, RecordsCupSigningDisabledEvent) {
  base::HistogramTester histogram_tester;
  InitCupFeatures(false, false);
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        return std::move(loader);
      });
  EXPECT_CALL(*loader, AttachStringForUpload(Matcher<const std::string&>(_),
                                             Matcher<const std::string&>(_)));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(mock_access_token_fetcher_, OnFetchAccessToken)
      .WillOnce(RunOnceCallback<0>(true, "access_token"));

  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ &mock_access_token_fetcher_,
      std::move(cup_factory), std::move(loader_factory),
      /* api_key = */ std::string("")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::OAUTH_WITH_API_KEY_FALLBACK,
      mock_response_callback_.Get(), autofill_assistant::RpcType::GET_ACTIONS);
  histogram_tester.ExpectUniqueSample(
      "Android.AutofillAssistant.CupRpcVerificationEvent",
      Metrics::CupRpcVerificationEvent::SIGNING_DISABLED, 1);
}

TEST_F(ServiceRequestSenderImplTest, RecordsCupVerificationDisabledEvent) {
  base::HistogramTester histogram_tester;
  InitCupFeatures(true, false);
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto cup = std::make_unique<NiceMock<autofill_assistant::cup::MockCUP>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        return std::move(loader);
      });
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));

  EXPECT_CALL(*cup_factory,
              CreateInstance(autofill_assistant::RpcType::GET_ACTIONS))
      .WillOnce([&]() { return std::move(cup); });
  EXPECT_CALL(*cup, PackAndSignRequest("request"))
      .WillOnce(Return(std::string("signed_request")));
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ nullptr, std::move(cup_factory),
      std::move(loader_factory), std::string("fake_api_key")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::API_KEY, mock_response_callback_.Get(),
      RpcType::GET_ACTIONS);
  histogram_tester.ExpectUniqueSample(
      "Android.AutofillAssistant.CupRpcVerificationEvent",
      Metrics::CupRpcVerificationEvent::VERIFICATION_DISABLED, 1);
}

TEST_F(ServiceRequestSenderImplTest, RecordsHttpFailureEventWithCupEnabled) {
  base::HistogramTester histogram_tester;
  InitCupFeatures(true, true);
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto cup = std::make_unique<NiceMock<autofill_assistant::cup::MockCUP>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_NOT_FOUND, "Not found");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        return std::move(loader);
      });
  EXPECT_CALL(*loader, AttachStringForUpload(Matcher<const std::string&>(_),
                                             Matcher<const std::string&>(_)));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(
          RunOnceCallback<1>(std::make_unique<std::string>("packed_response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_NOT_FOUND, "", _));
  EXPECT_CALL(*cup_factory, CreateInstance).WillOnce([&]() {
    return std::move(cup);
  });
  EXPECT_CALL(*cup, PackAndSignRequest("request")).WillOnce([&]() {
    return "signed_request";
  });

  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ nullptr, std::move(cup_factory),
      std::move(loader_factory), std::string("fake_api_key")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::API_KEY, mock_response_callback_.Get(),
      autofill_assistant::RpcType::GET_ACTIONS);

  histogram_tester.ExpectBucketCount(
      "Android.AutofillAssistant.CupRpcVerificationEvent",
      Metrics::CupRpcVerificationEvent::HTTP_FAILED, 1);
}

TEST_F(ServiceRequestSenderImplTest, RecordsHttpFailureEventWithCupDisabled) {
  base::HistogramTester histogram_tester;
  InitCupFeatures(false, false);
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto cup = std::make_unique<NiceMock<autofill_assistant::cup::MockCUP>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_NOT_FOUND, "Not found");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        return std::move(loader);
      });
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(
          RunOnceCallback<1>(std::make_unique<std::string>("packed_response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_NOT_FOUND, "", _));
  EXPECT_CALL(*cup_factory, CreateInstance).WillOnce([&]() {
    return std::move(cup);
  });

  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ nullptr, std::move(cup_factory),
      std::move(loader_factory), std::string("fake_api_key")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::API_KEY, mock_response_callback_.Get(),
      autofill_assistant::RpcType::GET_ACTIONS);

  histogram_tester.ExpectBucketCount(
      "Android.AutofillAssistant.CupRpcVerificationEvent",
      Metrics::CupRpcVerificationEvent::HTTP_FAILED, 1);
}

TEST_F(ServiceRequestSenderImplTest,
       DoesNotRecordCupDisabledEventIfVerificationPerformed) {
  base::HistogramTester histogram_tester;
  InitCupFeatures(true, true);
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto cup = std::make_unique<NiceMock<autofill_assistant::cup::MockCUP>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        return std::move(loader);
      });
  EXPECT_CALL(*loader, AttachStringForUpload(Matcher<const std::string&>(_),
                                             Matcher<const std::string&>(_)));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(
          RunOnceCallback<1>(std::make_unique<std::string>("packed_response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));
  EXPECT_CALL(*cup_factory, CreateInstance).WillOnce([&]() {
    return std::move(cup);
  });
  EXPECT_CALL(*cup, PackAndSignRequest("request")).WillOnce([&]() {
    return "signed_request";
  });
  EXPECT_CALL(*cup, UnpackResponse("packed_response")).WillOnce([&]() {
    return "response";
  });

  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ nullptr, std::move(cup_factory),
      std::move(loader_factory), std::string("fake_api_key")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::API_KEY, mock_response_callback_.Get(),
      autofill_assistant::RpcType::GET_ACTIONS);

  histogram_tester.ExpectUniqueSample(
      "Android.AutofillAssistant.CupRpcVerificationEvent",
      Metrics::CupRpcVerificationEvent::SIGNING_DISABLED, 0);
  histogram_tester.ExpectUniqueSample(
      "Android.AutofillAssistant.CupRpcVerificationEvent",
      Metrics::CupRpcVerificationEvent::HTTP_FAILED, 0);
  histogram_tester.ExpectBucketCount(
      "Android.AutofillAssistant.CupRpcVerificationEvent",
      Metrics::CupRpcVerificationEvent::VERIFICATION_DISABLED, 0);
}

TEST_F(ServiceRequestSenderImplTest, DoesNotRecordCupEventForNonSupportedRpcs) {
  base::HistogramTester histogram_tester;
  InitCupFeatures(true, true);
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        return std::move(loader);
      });
  EXPECT_CALL(*loader, AttachStringForUpload(Matcher<const std::string&>(_),
                                             Matcher<const std::string&>(_)));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));

  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ &mock_access_token_fetcher_,
      std::move(cup_factory), std::move(loader_factory),
      /* api_key = */ std::string("fake_api_key")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::API_KEY, mock_response_callback_.Get(),
      autofill_assistant::RpcType::GET_TRIGGER_SCRIPTS);

  histogram_tester.ExpectUniqueSample(
      "Android.AutofillAssistant.CupRpcVerificationEvent",
      Metrics::CupRpcVerificationEvent::SIGNING_DISABLED, 0);
  histogram_tester.ExpectUniqueSample(
      "Android.AutofillAssistant.CupRpcVerificationEvent",
      Metrics::CupRpcVerificationEvent::HTTP_FAILED, 0);
  histogram_tester.ExpectBucketCount(
      "Android.AutofillAssistant.CupRpcVerificationEvent",
      Metrics::CupRpcVerificationEvent::VERIFICATION_DISABLED, 0);
}

TEST_F(ServiceRequestSenderImplTest,
       DoesNotPerformCupSigningIfRpcSigningDisabled) {
  InitCupFeatures(true, true);
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        return std::move(loader);
      });
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));

  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  EXPECT_CALL(*cup_factory, CreateInstance).Times(0);

  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ nullptr, std::move(cup_factory),
      std::move(loader_factory), std::string("fake_api_key")};
  request_sender.SetDisableRpcSigning(true);
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::API_KEY, mock_response_callback_.Get(),
      autofill_assistant::RpcType::GET_ACTIONS);
}

TEST_F(ServiceRequestSenderImplTest, TestRetryLoggingForGetUserData) {
  base::HistogramTester histogram_tester;
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto* loader_ptr = loader.get();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        return std::move(loader);
      });
  EXPECT_CALL(*loader_ptr, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  EXPECT_CALL(*loader_ptr, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(*loader_ptr, GetNumRetries).WillOnce(Return(1));
  EXPECT_CALL(mock_access_token_fetcher_, OnFetchAccessToken)
      .WillOnce(RunOnceCallback<0>(true, "access_token"));
  EXPECT_CALL(mock_access_token_fetcher_, InvalidateAccessToken).Times(0);
  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));

  ServiceRequestSenderImpl request_sender{
      &context_, &mock_access_token_fetcher_, /* cup_factory= */ nullptr,
      std::move(loader_factory),
      /* api_key= */ std::string()};
  request_sender.SendRequest(GURL("https://www.example.com"),
                             std::string("request"),
                             ServiceRequestSender::AuthMode::OAUTH_STRICT,
                             mock_response_callback_.Get(),
                             autofill_assistant::RpcType::GET_USER_DATA);

  histogram_tester.ExpectBucketCount(
      "Android.AutofillAssistant.ServiceRequestSender.SuccessRetryCount", 1, 1);
}

TEST_F(ServiceRequestSenderImplTest, TestNoRetryLoggingForSupportsScripts) {
  base::HistogramTester histogram_tester;
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto* loader_ptr = loader.get();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        return std::move(loader);
      });
  EXPECT_CALL(*loader_ptr, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  EXPECT_CALL(*loader_ptr, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status_));
  EXPECT_CALL(*loader_ptr, GetNumRetries).Times(0);
  EXPECT_CALL(mock_access_token_fetcher_, OnFetchAccessToken)
      .WillOnce(RunOnceCallback<0>(true, "access_token"));
  EXPECT_CALL(mock_access_token_fetcher_, InvalidateAccessToken).Times(0);
  EXPECT_CALL(mock_response_callback_, Run(net::HTTP_OK, "response", _));

  ServiceRequestSenderImpl request_sender{
      &context_, &mock_access_token_fetcher_, /* cup_factory= */ nullptr,
      std::move(loader_factory),
      /* api_key= */ std::string()};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::OAUTH_WITH_API_KEY_FALLBACK,
      mock_response_callback_.Get(),
      autofill_assistant::RpcType::SUPPORTS_SCRIPT);

  histogram_tester.ExpectTotalCount(
      "Android.AutofillAssistant.ServiceRequestSender.SuccessRetryCount", 0);
  histogram_tester.ExpectTotalCount(
      "Android.AutofillAssistant.ServiceRequestSender.FailureRetryCount", 0);
}

TEST_F(ServiceRequestSenderImplTest, EncodedBodyLengthSet) {
  auto cup_factory =
      std::make_unique<NiceMock<autofill_assistant::cup::MockCUPFactory>>();
  auto loader_factory =
      std::make_unique<NiceMock<MockSimpleURLLoaderFactory>>();
  auto loader = std::make_unique<NiceMock<MockURLLoader>>();
  auto response_info = CreateResponseInfo(net::HTTP_OK, "OK");
  EXPECT_CALL(*loader_factory, OnCreateLoader)
      .WillOnce([&](::network::ResourceRequest* resource_request,
                    const ::net::NetworkTrafficAnnotationTag& annotation_tag) {
        return std::move(loader);
      });

  EXPECT_CALL(*loader,
              AttachStringForUpload(std::string("request"),
                                    std::string("application/x-protobuffer")));
  EXPECT_CALL(*loader, DownloadToStringOfUnboundedSizeUntilCrashAndDie)
      .WillOnce(RunOnceCallback<1>(std::make_unique<std::string>("response")));
  EXPECT_CALL(*loader, ResponseInfo)
      .WillRepeatedly(Return(response_info.get()));

  auto completion_status = absl::make_optional<URLLoaderCompletionStatus>();
  completion_status->encoded_body_length = 1337;
  EXPECT_CALL(*loader, CompletionStatus)
      .WillRepeatedly(ReturnRef(completion_status));

  EXPECT_CALL(
      mock_response_callback_,
      Run(_, _,
          Field(&ServiceRequestSender::ResponseInfo::encoded_body_length,
                1337)));
  ServiceRequestSenderImpl request_sender{
      &context_,
      /* access_token_fetcher = */ nullptr, std::move(cup_factory),
      std::move(loader_factory), std::string("fake_api_key")};
  request_sender.SendRequest(
      GURL("https://www.example.com"), std::string("request"),
      ServiceRequestSender::AuthMode::API_KEY, mock_response_callback_.Get(),
      RpcType::GET_TRIGGER_SCRIPTS);
}

// TODO(b/170934170): Add tests for full unit test coverage of
// service_request_sender.

}  // namespace
}  // namespace autofill_assistant


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<TITLE>
rabbit.test (RabbIT/4)
</TITLE>

<META NAME="date" CONTENT="2012-02-16">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">

rabbit.test

Classes

TestHttpHeaderReader


text:
import { COMMENT, DELIMCHANGE, SECTION, INVERTED } from 'config/types';
import { lastItem } from 'utils/array';
import { isString } from 'utils/is';

const leadingLinebreak = /^[ \t\f\r\n]*\r?\n/;
const trailingLinebreak = /\r?\n[ \t\f\r\n]*$/;

export default function(items) {
  let i, current, backOne, backTwo, lastSectionItem;

  for (i = 1; i < items.length; i += 1) {
    current = items[i];
    backOne = items[i - 1];
    backTwo = items[i - 2];

    // if we're at the end of a [text][comment][text] sequence...
    if (isString(current) && isComment(backOne) && isString(backTwo)) {
      // ... and the comment is a standalone (i.e. line breaks either side)...
      if (trailingLinebreak.test(backTwo) && leadingLinebreak.test(current)) {
        // ... then we want to remove the whitespace after the first line break
        items[i - 2] = backTwo.replace(trailingLinebreak, '\n');

        // and the leading line break of the second text token
        items[i] = current.replace(leadingLinebreak, '');
      }
    }

    // if the current item is a section, and it is preceded by a linebreak, and
    // its first item is a linebreak...
    if (isSection(current) && isString(backOne)) {
      if (
        trailingLinebreak.test(backOne) &&
        isString(current.f[0]) &&
        leadingLinebreak.test(current.f[0])
      ) {
        items[i - 1] = backOne.replace(trailingLinebreak, '\n');
        current.f[0] = current.f[0].replace(leadingLinebreak, '');
      }
    }

    // if the last item was a section, and it is followed by a linebreak, and
    // its last item is a linebreak...
    if (isString(current) && isSection(backOne)) {
      lastSectionItem = lastItem(backOne.f);

      if (
        isString(lastSectionItem) &&
        trailingLinebreak.test(lastSectionItem) &&
        leadingLinebreak.test(current)
      ) {
        backOne.f[backOne.f.length - 1] = lastSectionItem.replace(trailingLinebreak, '\n');
        items[i] = current.replace(leadingLinebreak, '');
      }
    }
  }

  return items;
}

function isComment(item) {
  return item.t === COMMENT || item.t === DELIMCHANGE;
}

function isSection(item) {
  return (item.t === SECTION || item.t === INVERTED) && item.f;
}


text:
package null

import (
	"sync"

	"github.com/docker/libnetwork/driverapi"
	"github.com/docker/libnetwork/types"
)

const networkType = "null"

type driver struct {
	network string
	sync.Mutex
}

// Init registers a new instance of null driver
func Init(dc driverapi.DriverCallback) error {
	c := driverapi.Capability{
		Scope: driverapi.LocalScope,
	}
	return dc.RegisterDriver(networkType, &driver{}, c)
}

func (d *driver) Config(option map[string]interface{}) error {
	return nil
}

func (d *driver) CreateNetwork(id string, option map[string]interface{}) error {
	d.Lock()
	defer d.Unlock()

	if d.network != "" {
		return types.ForbiddenErrorf("only one instance of \"%s\" network is allowed", networkType)
	}

	d.network = id

	return nil
}

func (d *driver) DeleteNetwork(nid string) error {
	return types.ForbiddenErrorf("network of type \"%s\" cannot be deleted", networkType)
}

func (d *driver) CreateEndpoint(nid, eid string, epInfo driverapi.EndpointInfo, epOptions map[string]interface{}) error {
	return nil
}

func (d *driver) DeleteEndpoint(nid, eid string) error {
	return nil
}

func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
	return make(map[string]interface{}, 0), nil
}

// Join method is invoked when a Sandbox is attached to an endpoint.
func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
	return nil
}

// Leave method is invoked when a Sandbox detaches from an endpoint.
func (d *driver) Leave(nid, eid string) error {
	return nil
}

func (d *driver) Type() string {
	return networkType
}


text:
HumboldtJS Library
==================

## What is it?

HumboldtJS Library is the standard library to use with HumboldtJS. It is
similar in function to the playerglobal.swc in Flash and provides standard
things like a DisplayObject, a Stage, EventDispatcher and a number of
utility classes to deal with the DOM.

This library is essential when developing HumboldtJS applications.

## What do I do with it?

Usually you will only want the *bin/HumboldtJSLibrary.swc*,
*lib/HumboldtJSDOM.swc* and *dom* folder and drop that into your project.
You can safely ignore the rest of this repository. The rest is only needed
if you want to fix bugs in the standard library or expand the functionality.

Unless you want to do these things you are probably better off starting with
the HumboldJSEmpty project, so check that out first.

## How to build it?

After cloning this repository you can import the folder as an existing project
in Adobe Flash Builder. This may not be needed depending on your usage
scenario. Actually building the library is done by running the ant build
script in the *build* folder.

Note that you may need to update the *FLEX_HOME* path in the ant build.xml