Skip to content

Commit

Permalink
Add regression test for #554 (#721)
Browse files Browse the repository at this point in the history
Fixes #709

This is a TS test because it cannot currently be expressed in YAML
(pulumi/pulumi-yaml#562).

When a version of Pulumi YAML releases with
pulumi/pulumi-yaml#563, we can rewrite the test
in YAML and incorporate it in our upgrade framework, making it _just
another test_ like those in
#719.
  • Loading branch information
iwahbe authored Apr 4, 2024
1 parent 9393b6e commit 26d4df4
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 11 deletions.
9 changes: 9 additions & 0 deletions examples/examples_nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ func TestRegress444(t *testing.T) {
integration.ProgramTest(t, &test)
}

func TestRegress554(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: filepath.Join(getCwd(t), "regress-554"),
})

integration.ProgramTest(t, &test)
}

func getJSBaseOptions(t *testing.T) integration.ProgramTestOptions {
base := getBaseOptions(t)
baseJS := base.With(integration.ProgramTestOptions{
Expand Down
2 changes: 2 additions & 0 deletions examples/regress-554/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: regress-554
runtime: nodejs
47 changes: 47 additions & 0 deletions examples/regress-554/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";

/*
* This is a regression test for https://github.com/pulumi/pulumi-cloudflare/issues/554.
*
* #554 triggers when calling READ (importing) on a `cloudflare.Ruleset` with non-empty
* rules values. We do this by creating a `cloudflare.Ruleset` (`ruleset`), and then
* calling `cloudflare.Ruleset.get` with the ID from `ruleset`. We do it this way so we
* *know* there is a valid cloudflare ruleset to import.
*
* We don't need to assert on the imported ruleset, since #554 presented as a panic, not
* as incorrect data.
*/

const accountId = pulumi.secret(process.env["CLOUDFLARE_ACCOUNT_ID"]!);

const zone = cloudflare.getZoneOutput({
accountId,
name: "pulumi-cloudflare-demo.com",
})

const ruleset = new cloudflare.Ruleset("domain-rate-limit", {
name: "domain-rate-limit",
kind: "zone",
zoneId: zone.zoneId,
phase: "http_request_transform",

rules: [{
action: "rewrite",
actionParameters: {
uri: {
path: {
value: "/my-new-route"
}
}
},

expression: "(http.host eq \"example.com\" and http.request.uri.path eq \"/old-path\")",
description: "example URI path transform rule",
enabled: true,
}],
});

export const importName = pulumi.interpolate`zone/${zone.id}/${ruleset.id}`;

cloudflare.Ruleset.get("imported", importName);
11 changes: 11 additions & 0 deletions examples/regress-554/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "cloudflare-ruleset-import",
"version": "0.1.0",
"dependencies": {
"@pulumi/cloudflare": "^5.0.0",
"@pulumi/pulumi": "^3.0.0"
},
"devDependencies": {
"@types/node": "^12.0.0"
}
}
21 changes: 21 additions & 0 deletions examples/regress-554/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"outDir": "bin",
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"stripInternal": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true,
"strictNullChecks": true
},
"files": [
"index.ts"
]
}
8 changes: 4 additions & 4 deletions provider/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.21

require (
github.com/cloudflare/terraform-provider-cloudflare v1.18.2-0.20220823222840-b2cee3be8c57
github.com/pulumi/pulumi-terraform-bridge/pf v0.32.0
github.com/pulumi/pulumi-terraform-bridge/v3 v3.79.0
github.com/pulumi/pulumi-terraform-bridge/pf v0.32.1-0.20240403143912-aaea88a50769
github.com/pulumi/pulumi-terraform-bridge/v3 v3.79.1-0.20240403143912-aaea88a50769
)

replace github.com/cloudflare/terraform-provider-cloudflare => ../upstream
Expand Down Expand Up @@ -89,7 +89,7 @@ require (
github.com/golang-jwt/jwt/v5 v5.1.0 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
Expand Down Expand Up @@ -181,7 +181,7 @@ require (
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect
github.com/pulumi/esc v0.6.2 // indirect
github.com/pulumi/pulumi-java/pkg v0.10.0 // indirect
github.com/pulumi/pulumi-terraform-bridge/x/muxer v0.0.9-0.20240401182119-4a13c5f233f1 // indirect
github.com/pulumi/pulumi-terraform-bridge/x/muxer v0.0.9-0.20240403143912-aaea88a50769 // indirect
github.com/pulumi/pulumi-yaml v1.6.0 // indirect
github.com/pulumi/pulumi/pkg/v3 v3.112.0 // indirect
github.com/pulumi/pulumi/sdk/v3 v3.112.0 // indirect
Expand Down
15 changes: 8 additions & 7 deletions provider/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1994,8 +1994,9 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
Expand Down Expand Up @@ -2841,12 +2842,12 @@ github.com/pulumi/providertest v0.0.11 h1:mg8MQ7Cq7+9XlHIkBD+aCqQO4mwAJEISngZgVd
github.com/pulumi/providertest v0.0.11/go.mod h1:HsxjVsytcMIuNj19w1lT2W0QXY0oReXl1+h6eD2JXP8=
github.com/pulumi/pulumi-java/pkg v0.10.0 h1:D1i5MiiNrxYr2uJ1szcj1aQwF9DYv7TTsPmajB9dKSw=
github.com/pulumi/pulumi-java/pkg v0.10.0/go.mod h1:xu6UgYtQm+xXOo1/DZNa2CWVPytu+RMkZVTtI7w7ffY=
github.com/pulumi/pulumi-terraform-bridge/pf v0.32.0 h1:+yOxg6ulqRrRBNyBU1q28F6KDNjOgFV9EkhZU9ZLR/s=
github.com/pulumi/pulumi-terraform-bridge/pf v0.32.0/go.mod h1:pWkGrl4GPwWcMevCZMxSzkYw36s0tN0/a/W1oK4SwPU=
github.com/pulumi/pulumi-terraform-bridge/v3 v3.79.0 h1:h0HlgUsqaQAe57/+AP9kbhHo5SLI0uwl8lstjVG+I9U=
github.com/pulumi/pulumi-terraform-bridge/v3 v3.79.0/go.mod h1:U5CqG4BJmdzCd4ALO2cx/dEP0yTHfIS2sk2ah1ngZq4=
github.com/pulumi/pulumi-terraform-bridge/x/muxer v0.0.9-0.20240401182119-4a13c5f233f1 h1:Y7Vh+5pbN+ijjidzvTIMJ0bU46uaqKd5EDCXM8Gznpg=
github.com/pulumi/pulumi-terraform-bridge/x/muxer v0.0.9-0.20240401182119-4a13c5f233f1/go.mod h1:cBPPrOKBFI2uKZRc0yMn9FGk0nD2939WLNg6tLnuQ6Y=
github.com/pulumi/pulumi-terraform-bridge/pf v0.32.1-0.20240403143912-aaea88a50769 h1:1UKnJJ/xtyvsOgm93wBKkAdVqX1jQRYeKsK4IpaiB2Y=
github.com/pulumi/pulumi-terraform-bridge/pf v0.32.1-0.20240403143912-aaea88a50769/go.mod h1:/LAuVSafXgrVhz6nPly/GYWkgEuPU3UXjxxVxiiqCcc=
github.com/pulumi/pulumi-terraform-bridge/v3 v3.79.1-0.20240403143912-aaea88a50769 h1:RgUTbgRdYiM5aEH7iaX9HQaHuW1U4FCT0QfiDT2+Cl0=
github.com/pulumi/pulumi-terraform-bridge/v3 v3.79.1-0.20240403143912-aaea88a50769/go.mod h1:VzIl/lDqPfHpYq2UQQvY6YHeSXwt0+riqc8eNpK+ElA=
github.com/pulumi/pulumi-terraform-bridge/x/muxer v0.0.9-0.20240403143912-aaea88a50769 h1:AMzse6u2fuH9/i1boEJCuAf8Rol7YIOzfYMAya1KlfI=
github.com/pulumi/pulumi-terraform-bridge/x/muxer v0.0.9-0.20240403143912-aaea88a50769/go.mod h1:cBPPrOKBFI2uKZRc0yMn9FGk0nD2939WLNg6tLnuQ6Y=
github.com/pulumi/pulumi-yaml v1.6.0 h1:mb/QkebWXTa1fR+P3ZkCCHGXOYC6iTN8X8By9eNz8xM=
github.com/pulumi/pulumi-yaml v1.6.0/go.mod h1:RyEPo4MhL363sbAiFMVKRsQmXpQPDCY1S8pGv3E6Ij0=
github.com/pulumi/pulumi/pkg/v3 v3.112.0 h1:vhoM6sx1eegJntIeUZENtck3VeMtK1zBiQ2E3EPOnHw=
Expand Down

0 comments on commit 26d4df4

Please sign in to comment.