Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set createNew to true in AssignMessage policies used for response #35

Merged
merged 4 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/provision/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func newHash() (string, error) {

t := time.Now()
h := sha256.New()
if _, err := h.Write([]byte(t.String() + string(rnd.Int()))); err != nil {
if _, err := h.Write([]byte(t.String() + string(rune(rnd.Int())))); err != nil {
return "", err
}
str := hex.EncodeToString(h.Sum(nil))
Expand Down
9 changes: 0 additions & 9 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,12 @@ import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"

"github.com/apigee/apigee-remote-service-cli/shared"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)

func init() {
// Apigee does not support http2 at present
if !strings.Contains(os.Getenv("GODEBUG"), "http2client=0") {
os.Setenv("GODEBUG", os.Getenv("GODEBUG")+",http2client=0")
}
}

// GetRootCmd returns the root of the cobra command-tree.
func GetRootCmd(args []string, printf shared.FormatFn) *cobra.Command {
c := &cobra.Command{
Expand Down
10 changes: 0 additions & 10 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,12 @@ import (
"encoding/json"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"

"github.com/apigee/apigee-remote-service-cli/shared"
"github.com/apigee/apigee-remote-service-cli/testutil"
)

func TestForceHttp11(t *testing.T) {

env := os.Getenv("GODEBUG")
if !strings.Contains(env, "http2client=0") {
t.Errorf("expected GODEBUG to include 'http2client=0' get %s", env)
}
}

func TestVersion(t *testing.T) {

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/apigee/apigee-remote-service-cli

go 1.13
go 1.14

// replace github.com/apigee/apigee-remote-service-golib => ../apigee-remote-service-golib

Expand Down
12 changes: 6 additions & 6 deletions proxies/proxies.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Do NOT edit or pull out this policy from the proxies! -->
<!-- This policy is used to create a new response without mixing with any request headers for an http2 client. -->
<AssignMessage async="false" continueOnError="false" enabled="true" name="Create-New-Response">
<DisplayName>CreateNewResponse</DisplayName>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="true" transport="http" type="response"/>
</AssignMessage>
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
<StatusCode>200</StatusCode>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="true" type="response"/>
</AssignMessage>
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<Payload contentType="application/json" variablePrefix="@" variableSuffix="#">@productlist#</Payload>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="response"/>
<AssignTo createNew="true" transport="http" type="response"/>
</AssignMessage>
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
}</Payload>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
<AssignTo createNew="true" transport="http" type="response"/>
</AssignMessage>
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
}</Payload>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" type="response"/>
<AssignTo createNew="true" type="response"/>
</AssignMessage>
10 changes: 10 additions & 0 deletions proxies/remote-proxy-gcp/apiproxy/proxies/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
</Step>
</Request>
<Response>
<Step>
<Name>Create-New-Response</Name>
</Step>
<Step>
<Name>Set-Response</Name>
</Step>
Expand All @@ -51,6 +54,10 @@
</Step>
</Request>
<Response>
<Step>
<Name>Create-New-Response</Name>
<Condition>lookupcache.Lookup-Products.cachehit = false</Condition>
</Step>
<Step>
<Name>JavaCallout</Name>
<Condition>lookupcache.Lookup-Products.cachehit = false</Condition>
Expand Down Expand Up @@ -107,6 +114,9 @@
</Step>
</Request>
<Response>
<Step>
<Name>Create-New-Response</Name>
</Step>
<Step>
<Name>Set-Response</Name>
</Step>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<StatusCode>200</StatusCode>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="true" transport="http" type="response"/>
</AssignMessage>
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<Payload contentType="application/json" variablePrefix="@" variableSuffix="#">@productlist#</Payload>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="response"/>
<AssignTo createNew="true" transport="http" type="response"/>
</AssignMessage>
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<Payload contentType="application/json">{"version":"1.0.0"}</Payload>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
<AssignTo createNew="true" transport="http" type="response"/>
</AssignMessage>
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
}</Payload>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" type="response"/>
<AssignTo createNew="true" type="response"/>
</AssignMessage>