Skip to content

Commit

Permalink
Revert "Prebid upgrade 0.146.0 ci1 (#117)"
Browse files Browse the repository at this point in the history
This reverts commit 984ee22.
  • Loading branch information
PubMatic-OpenWrap authored Feb 17, 2021
1 parent 984ee22 commit b1de2fe
Show file tree
Hide file tree
Showing 679 changed files with 8,353 additions and 24,839 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/validate-merge.yml

This file was deleted.

23 changes: 9 additions & 14 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
name: Validate

on:
push:
branches: [master]
branches:
- master
pull_request:
branches: [master]

release:
types:
- created
name: Validate
jobs:
validate:
Go:
strategy:
matrix:
go-version: [1.14.x, 1.15.x]
go-version: [1.13.x, 1.14.x, 1.15.x]
os: [ubuntu-18.04]
runs-on: ${{ matrix.os }}

steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Checkout Branch
- name: Checkout code
uses: actions/checkout@v2
with:
# Resolves to empty string for push events and falls back to HEAD.
ref: ${{ github.event.pull_request.head.sha }}

- name: Validate
run: |
./validate.sh --nofmt --cov --race 10
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: go

go:
- '1.13'
- '1.14.2'
- '1.15'

go_import_path: github.com/PubMatic-OpenWrap/prebid-server

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ RUN apt-get update && \
apt-get install -y ca-certificates mtr && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
EXPOSE 8000
EXPOSE 6060
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/prebid-server"]
CMD ["-v", "1", "-logtostderr"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For more information, see:

## Installation

First install [Go](https://golang.org/doc/install) version 1.14 or newer.
First install [Go](https://golang.org/doc/install) version 1.13 or newer.

Note that prebid-server is using [Go modules](https://blog.golang.org/using-go-modules).
We officially support the most recent two major versions of the Go runtime. However, if you'd like to use a version <1.13 and are inside GOPATH `GO111MODULE` needs to be set to `GO111MODULE=on`.
Expand Down
4 changes: 2 additions & 2 deletions account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/PubMatic-OpenWrap/prebid-server/config"
"github.com/PubMatic-OpenWrap/prebid-server/errortypes"
"github.com/PubMatic-OpenWrap/prebid-server/metrics"
"github.com/PubMatic-OpenWrap/prebid-server/pbsmetrics"
"github.com/PubMatic-OpenWrap/prebid-server/stored_requests"
jsonpatch "github.com/evanphx/json-patch"
)
Expand All @@ -20,7 +20,7 @@ func GetAccount(ctx context.Context, cfg *config.Configuration, fetcher stored_r
Message: fmt.Sprintf("Prebid-server has disabled Account ID: %s, please reach out to the prebid server host.", accountID),
}}
}
if cfg.AccountRequired && accountID == metrics.PublisherUnknown {
if cfg.AccountRequired && accountID == pbsmetrics.PublisherUnknown {
return nil, []error{&errortypes.AcctRequired{
Message: fmt.Sprintf("Prebid-server has been configured to discard requests without a valid Account ID. Please reach out to the prebid server host."),
}}
Expand Down
4 changes: 2 additions & 2 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/PubMatic-OpenWrap/prebid-server/config"
"github.com/PubMatic-OpenWrap/prebid-server/errortypes"
"github.com/PubMatic-OpenWrap/prebid-server/metrics"
"github.com/PubMatic-OpenWrap/prebid-server/pbsmetrics"
"github.com/PubMatic-OpenWrap/prebid-server/stored_requests"
"github.com/stretchr/testify/assert"
)
Expand All @@ -29,7 +29,7 @@ func (af mockAccountFetcher) FetchAccount(ctx context.Context, accountID string)
}

func TestGetAccount(t *testing.T) {
unknown := metrics.PublisherUnknown
unknown := pbsmetrics.PublisherUnknown
testCases := []struct {
accountID string
// account_required
Expand Down
129 changes: 42 additions & 87 deletions adapters/33across/33across.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/PubMatic-OpenWrap/openrtb"
"github.com/PubMatic-OpenWrap/prebid-server/adapters"
"github.com/PubMatic-OpenWrap/prebid-server/config"
"github.com/PubMatic-OpenWrap/prebid-server/errortypes"
"github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext"
)
Expand All @@ -17,31 +16,14 @@ type TtxAdapter struct {
}

type Ext struct {
Ttx impTtxExt `json:"ttx"`
Ttx ext `json:"ttx"`
}

type impTtxExt struct {
type ext struct {
Prod string `json:"prod"`
Zoneid string `json:"zoneid,omitempty"`
}

type reqExt struct {
Ttx *reqTtxExt `json:"ttx,omitempty"`
}

type reqTtxExt struct {
Caller []TtxCaller `json:"caller,omitempty"`
}

type TtxCaller struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
}

// CALLER Info used to track Prebid Server
// as one of the hops in the request to exchange
var CALLER = TtxCaller{"Prebid-Server", "n/a"}

type bidExt struct {
Ttx bidTtxExt `json:"ttx,omitempty"`
}
Expand All @@ -55,41 +37,39 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters
var errs []error
var adapterRequests []*adapters.RequestData

// Construct request extension common to all imps
// NOTE: not blocking adapter requests on errors
// since request extension is optional.
reqExt, err := makeReqExt(request)
if err != nil {
errs = append(errs, err)
}
request.Ext = reqExt

// Break up multi-imp request into multiple external requests since we don't
// support SRA in our exchange server
for i := 0; i < len(request.Imp); i++ {
if adapterReq, err := a.makeRequest(*request, request.Imp[i]); err == nil {
adapterRequests = append(adapterRequests, adapterReq)
} else {
errs = append(errs, err)
}
adapterReq, errors := a.makeRequest(request)
if adapterReq != nil {
adapterRequests = append(adapterRequests, adapterReq)
}
errs = append(errs, errors...)

return adapterRequests, errs
return adapterRequests, errors
}

func (a *TtxAdapter) makeRequest(request openrtb.BidRequest, imp openrtb.Imp) (*adapters.RequestData, error) {
impCopy, err := makeImps(imp)
// Update the request object to include custom value
// site.id
func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) {
var errs []error

if err != nil {
return nil, err
// Make a copy as we don't want to change the original request
reqCopy := *request
if err := preprocess(&reqCopy); err != nil {
errs = append(errs, err)
}

request.Imp = []openrtb.Imp{*impCopy}
if reqCopy.Imp[0].Banner == nil && reqCopy.Imp[0].Video == nil {
errs = append(errs, &errortypes.BadInput{
Message: "At least one of [banner, video] formats must be defined in Imp. None found",
})

return nil, errs
}

// Last Step
reqJSON, err := json.Marshal(request)
reqJSON, err := json.Marshal(reqCopy)
if err != nil {
return nil, err
errs = append(errs, err)
return nil, errs
}

headers := http.Header{}
Expand All @@ -100,47 +80,45 @@ func (a *TtxAdapter) makeRequest(request openrtb.BidRequest, imp openrtb.Imp) (*
Uri: a.endpoint,
Body: reqJSON,
Headers: headers,
}, nil
}, errs
}

func makeImps(imp openrtb.Imp) (*openrtb.Imp, error) {
if imp.Banner == nil && imp.Video == nil {
return nil, &errortypes.BadInput{
Message: fmt.Sprintf("Imp ID %s must have at least one of [Banner, Video] defined", imp.ID),
}
}

// Mutate the request to get it ready to send to ttx.
func preprocess(request *openrtb.BidRequest) error {
var imp = &request.Imp[0]
var bidderExt adapters.ExtImpBidder
if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
return nil, &errortypes.BadInput{
return &errortypes.BadInput{
Message: err.Error(),
}
}

var ttxExt openrtb_ext.ExtImp33across
if err := json.Unmarshal(bidderExt.Bidder, &ttxExt); err != nil {
return nil, &errortypes.BadInput{
return &errortypes.BadInput{
Message: err.Error(),
}
}

var impExt Ext
impExt.Ttx.Prod = ttxExt.ProductId

impExt.Ttx.Zoneid = ttxExt.SiteId

// Add zoneid if it's defined
if len(ttxExt.ZoneId) > 0 {
impExt.Ttx.Zoneid = ttxExt.ZoneId
}

impExtJSON, err := json.Marshal(impExt)
if err != nil {
return nil, &errortypes.BadInput{
return &errortypes.BadInput{
Message: err.Error(),
}
}

imp.Ext = impExtJSON
siteCopy := *request.Site
siteCopy.ID = ttxExt.SiteId
request.Site = &siteCopy

// Validate Video if it exists
if imp.Video != nil {
Expand All @@ -149,35 +127,13 @@ func makeImps(imp openrtb.Imp) (*openrtb.Imp, error) {
imp.Video = videoCopy

if err != nil {
return nil, &errortypes.BadInput{
return &errortypes.BadInput{
Message: err.Error(),
}
}
}

return &imp, nil
}

func makeReqExt(request *openrtb.BidRequest) ([]byte, error) {
var reqExt reqExt

if len(request.Ext) > 0 {
if err := json.Unmarshal(request.Ext, &reqExt); err != nil {
return nil, err
}
}

if reqExt.Ttx == nil {
reqExt.Ttx = &reqTtxExt{}
}

if reqExt.Ttx.Caller == nil {
reqExt.Ttx.Caller = make([]TtxCaller, 0)
}

reqExt.Ttx.Caller = append(reqExt.Ttx.Caller, CALLER)

return json.Marshal(reqExt)
return nil
}

// MakeBids make the bids for the bid response.
Expand Down Expand Up @@ -263,10 +219,9 @@ func getBidType(ext bidExt) openrtb_ext.BidType {
return openrtb_ext.BidTypeBanner
}

// Builder builds a new instance of the 33Across adapter for the given bidder with the given config.
func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) {
bidder := &TtxAdapter{
endpoint: config.Endpoint,
// New33AcrossBidder configures bidder endpoint
func New33AcrossBidder(endpoint string) *TtxAdapter {
return &TtxAdapter{
endpoint: endpoint,
}
return bidder, nil
}
11 changes: 1 addition & 10 deletions adapters/33across/33across_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,8 @@ import (
"testing"

"github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest"
"github.com/PubMatic-OpenWrap/prebid-server/config"
"github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext"
)

func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.Bidder33Across, config.Adapter{
Endpoint: "http://ssc.33across.com"})

if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
}

adapterstest.RunJSONBidderTest(t, "33acrosstest", bidder)
adapterstest.RunJSONBidderTest(t, "33acrosstest", New33AcrossBidder("http://ssc.33across.com"))
}
Loading

0 comments on commit b1de2fe

Please sign in to comment.