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

Add additional test cases #144

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
83 changes: 79 additions & 4 deletions examples/examples_nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
)

func TestGetDevicesTs(t *testing.T) {
t.Skip("Skipping Pulumi Test as this currently doesn't work. See https://github.com/pulumi/pulumi-meraki/issues/134 for more details")
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "get-devices-ts",
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "get-devices-ts",
opttest.LocalProviderPath("meraki", filepath.Join(getCwd(t), "..", "bin")),
)
test.SetConfig("organizationId", os.Getenv(EnvMerakiOrgID))
test.Preview()
}

func TestNetworkBaseTs(t *testing.T) {
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "network-base-ts",
Expand Down Expand Up @@ -55,6 +55,17 @@ func TestApplianceVlansTs(t *testing.T) {
test.Up()
}

func TestApplianceVlanProfilesTs(t *testing.T) {
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "network-appliance-vlan-profiles-ts",
opttest.LocalProviderPath("meraki", filepath.Join(getCwd(t), "..", "bin")),
opttest.YarnLink("@pulumi/meraki"),
)
test.SetConfig("organizationId", os.Getenv(EnvMerakiOrgID))
test.SetConfig("networkName", "Pulumi Base Test Network_" + randomString(6))
test.Up()
}

func TestAlertSettingsTs(t *testing.T) {
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "network-alert-settings-ts",
Expand All @@ -65,6 +76,7 @@ func TestAlertSettingsTs(t *testing.T) {
test.SetConfig("networkName", "Pulumi Base Test Network_" + randomString(6))
test.Up()
}

func TestApplianceContentFilterTs(t *testing.T) {
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "network-appliance-content-filtering-ts",
Expand All @@ -74,4 +86,67 @@ func TestApplianceContentFilterTs(t *testing.T) {
test.SetConfig("organizationId", os.Getenv(EnvMerakiOrgID))
test.SetConfig("networkName", "Pulumi Base Test Network_" + randomString(6))
test.Up()
}
}

func TestWebhooksHttpServersTs(t *testing.T) {
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "network-webhooks-http-servers-ts",
opttest.LocalProviderPath("meraki", filepath.Join(getCwd(t), "..", "bin")),
opttest.YarnLink("@pulumi/meraki"),
)
test.SetConfig("organizationId", os.Getenv(EnvMerakiOrgID))
test.SetConfig("networkName", "Pulumi Base Test Network_" + randomString(6))
test.Up()
}

func TestSyslogServersTs(t *testing.T) {
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "network-syslog-servers-ts",
opttest.LocalProviderPath("meraki", filepath.Join(getCwd(t), "..", "bin")),
opttest.YarnLink("@pulumi/meraki"),
)
test.SetConfig("organizationId", os.Getenv(EnvMerakiOrgID))
test.SetConfig("networkName", "Pulumi Base Test Network_" + randomString(6))
test.Up()
}
func TestNetworkApplianceSecurityIntrusionTs(t *testing.T) {
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "network-appliance-security-intrusion-ts",
opttest.LocalProviderPath("meraki", filepath.Join(getCwd(t), "..", "bin")),
opttest.YarnLink("@pulumi/meraki"),
)
test.SetConfig("organizationId", os.Getenv(EnvMerakiOrgID))
test.SetConfig("networkName", "Pulumi Base Test Network_" + randomString(6))
test.Up()

}
func TestNetworkApplianceSecurityMalwareTs(t *testing.T) {
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "network-appliance-security-malware-ts",
opttest.LocalProviderPath("meraki", filepath.Join(getCwd(t), "..", "bin")),
opttest.YarnLink("@pulumi/meraki"),
)
test.SetConfig("organizationId", os.Getenv(EnvMerakiOrgID))
test.SetConfig("networkName", "Pulumi Base Test Network_" + randomString(6))
test.Up()
}
func TestNetworkSwitchRoutingMulticastTs(t *testing.T) {
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "network-switch-routing-multicast-ts",
opttest.LocalProviderPath("meraki", filepath.Join(getCwd(t), "..", "bin")),
opttest.YarnLink("@pulumi/meraki"),
)
test.SetConfig("organizationId", os.Getenv(EnvMerakiOrgID))
test.SetConfig("networkName", "Pulumi Base Test Network_" + randomString(6))
test.Up()
}
func TestNetworkSwitchAccessPoliciesTs(t *testing.T) {
checkBaseEnvVars(t)
test := pulumitest.NewPulumiTest(t, "network-switch-access-policies-ts",
opttest.LocalProviderPath("meraki", filepath.Join(getCwd(t), "..", "bin")),
opttest.YarnLink("@pulumi/meraki"),
)
test.SetConfig("organizationId", os.Getenv(EnvMerakiOrgID))
test.SetConfig("networkName", "Pulumi Base Test Network_" + randomString(6))
test.Up()
}
11 changes: 0 additions & 11 deletions examples/network-appliance-security-intrusion-ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,9 @@ export = async () => {
tags: ["US-Env01-0001", "US-Env01-0002"],
});

// ERROR: "'protectedNetworks' is not supported by this network. Please ensure the network is set to 'passthrough' mode"
new meraki.networks.ApplianceSecurityIntrusion("example", {
idsRulesets: "balanced",
mode: "prevention",
networkId: network.id,
protectedNetworks: {
excludedCidrs: ["10.0.0.0/8", "127.0.0.0/8"],
includedCidrs: [
"10.0.0.0/8",
"127.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
],
useDefault: false,
},
});
};
17 changes: 0 additions & 17 deletions examples/network-appliance-security-malware-ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@ export = async () => {
});

new meraki.networks.ApplianceSecurityMalware("example", {
allowedFiles: [
{
comment: "allow ZIP file",
sha256:
"e82c5f7d75004727e1f3b94426b9a11c8bc4c312a9170ac9a73abace40aef503",
},
],
allowedUrls: [
{
comment: "allow help.com.au",
url: "help.com.au",
},
{
comment: "allow google.com",
url: "google.com",
},
],
mode: "enabled",
networkId: network.id,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: meraki-network-webhooks-payload-templates-ts
name: meraki-network-appliance-vlan-profiles-ts
runtime: nodejs
description: A minimal TypeScript Pulumi program
70 changes: 70 additions & 0 deletions examples/network-appliance-vlan-profiles-ts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import * as pulumi from "@pulumi/pulumi";
import * as meraki from "@pulumi/meraki";

export = async () => {
const config = new pulumi.Config();
const organizationId = config.requireSecret("organizationId");
const networkName = config.get("networkName") || "Pulumi Base Test Network";

const network = new meraki.networks.Base("base-network", {
name: networkName,
notes:
"This is a test network created by the Pulumi team in an integration test.",
organizationId: organizationId,
productTypes: ["appliance", "switch", "wireless", "cellularGateway"],
timeZone: "America/Chicago",
tags: ["US-Env01-0001", "US-Env01-0002"],
});

const vlanSettings = new meraki.networks.ApplianceVlansSettings(
"vlan-settings",
{
networkId: network.id,
vlansEnabled: true,
}
);

const applianceVlan = new meraki.networks.ApplianceVlans(
"appliance-vlans",
{
name: "guest",
networkId: network.id,
vlanId: "2",
subnet: "192.168.2.0/24",
applianceIp: "192.168.2.1",
dhcpHandling: "Run a DHCP server",
dnsNameservers: "upstream_dns",
dhcpLeaseTime: "1 day",
dhcpBootOptionsEnabled: false,
reservedIpRanges: [
{ comment: "reserved", start: "192.168.2.2", end: "192.168.2.3" },
{ comment: "excluded", start: "192.168.2.4", end: "192.168.2.5" },
],
},
{ dependsOn: [vlanSettings] }
);

// The Default VLAN Profile is created by default when the network is created.
const vlanProfiles = new meraki.networks.VlanProfiles(
"vlan-profiles",
{
networkId: network.id,
name: "Default Profile",
iname: "Default",
vlanNames: [
{
name: "default",
vlanId: "1",
},
{
name: applianceVlan.name,
vlanId: applianceVlan.vlanId,
},
],
vlanGroups: [],
},
{
retainOnDelete: true, // Retain the VLAN profile, it will be deleted when the network is deleted.
}
);
};
12 changes: 12 additions & 0 deletions examples/network-appliance-vlan-profiles-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "meraki-network-appliance-vlan-profiles-ts",
"main": "index.ts",
"devDependencies": {
"@types/node": "^18",
"typescript": "^5.0.0"
},
"dependencies": {
"@pulumi/meraki": "^0.2.10",
"@pulumi/pulumi": "^3.113.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,37 @@ export = async () => {
tags: ["US-Env01-0001", "US-Env01-0002"],
});

new meraki.networks.SwitchAccessPolicies("example", {
accessPolicyType: "Hybrid authentication",
new meraki.networks.SwitchAccessPolicies("switch-access-policy", {
name: "Access policy Test",
networkId: network.id,
accessPolicyType: "MAC authentication bypass",
dot1x: {
controlDirection: "inbound",
controlDirection: "both",
},
guestPortBouncing: false,
guestVlanId: 100,
hostMode: "Single-Host",
increaseAccessSpeed: false,
name: "Access policy #1",
networkId: network.id,
radius: {
criticalAuth: {
dataVlanId: 100,
suspendPortBounce: true,
voiceVlanId: 100,
suspendPortBounce: false,
},
failedAuthVlanId: 100,
reAuthenticationInterval: 120,
},
radiusAccountingEnabled: true,
radiusAccountingServers: [
{
host: "1.2.3.4",
port: 22,
port: 1812,
secret: "secret",
},
],
radiusCoaSupportEnabled: false,
radiusGroupAttribute: "11",
radiusServers: [
{
host: "1.2.3.4",
port: 22,
port: 1812,
secret: "secret",
},
],
radiusTestingEnabled: false,
urlRedirectWalledGardenEnabled: true,
urlRedirectWalledGardenRanges: ["192.168.1.0/24"],
radiusTestingEnabled: true,
urlRedirectWalledGardenEnabled: false,
voiceVlanClients: true,
});
};
3 changes: 3 additions & 0 deletions examples/network-switch-routing-multicast-ts/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: meraki-network-switch-routing-multicast-ts
runtime: nodejs
description: A minimal TypeScript Pulumi program
26 changes: 26 additions & 0 deletions examples/network-switch-routing-multicast-ts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as pulumi from "@pulumi/pulumi";
import * as meraki from "@pulumi/meraki";

export = async () => {
const config = new pulumi.Config();
const organizationId = config.requireSecret("organizationId");
const networkName = config.get("networkName") || "Pulumi Base Test Network";

const network = new meraki.networks.Base("base-network", {
name: networkName,
notes:
"This is a test network created by the Pulumi team in an integration test.",
organizationId: organizationId,
productTypes: ["appliance", "switch", "wireless", "cellularGateway"],
timeZone: "America/Chicago",
tags: ["US-Env01-0001", "US-Env01-0002"],
});

new meraki.networks.SwitchRoutingMulticast("switch-routing-multicast", {
networkId: network.id,
defaultSettings: {
floodUnknownMulticastTrafficEnabled: true,
igmpSnoopingEnabled: false,
},
});
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "meraki-network-webhooks-payload-templates",
"name": "meraki-network-switch-routing-multicast-ts",
"main": "index.ts",
"devDependencies": {
"@types/node": "^18",
Expand Down
16 changes: 16 additions & 0 deletions examples/network-switch-routing-multicast-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"strict": true,
"outDir": "bin",
"target": "es2020",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.ts"]
}
10 changes: 7 additions & 3 deletions examples/network-syslog-servers-ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ export = async () => {
tags: ["US-Env01-0001", "US-Env01-0002"],
});

new meraki.networks.SyslogServers("example", {
new meraki.networks.SyslogServers("syslog-server", {
networkId: network.id,
servers: [
{
host: "1.2.3.4",
port: 22,
host: "192.0.2.1",
port: 8008,
roles: [
"Wireless event log",
"Appliance event log",
"Switch event log",
"Air Marshal events",
"Flows",
"URLs",
"Security events",
],
},
],
Expand Down
Loading
Loading