-
Notifications
You must be signed in to change notification settings - Fork 55
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
DXCDT-386: Expand logs test cases #663
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,6 +132,16 @@ func updateLogStreamsDatadogCmd(cli *cli) *cobra.Command { | |
return fmt.Errorf("failed to read log stream with ID %s: %w", inputs.ID, err) | ||
} | ||
|
||
if oldLogStream.GetType() != string(logStreamTypeDatadog) { | ||
return fmt.Errorf( | ||
"the log stream with ID %q is of type %q instead of datadog, "+ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe use |
||
"use 'auth0 logs streams update %s' to update it instead", | ||
inputs.ID, | ||
oldLogStream.GetType(), | ||
oldLogStream.GetType(), | ||
) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we prevent a panic down below when we type cast the sink property, this safeguards us against passing a real log stream ID but of different type. This is replicated in all the update commands. |
||
if err := logStreamName.AskU(cmd, &inputs.Name, oldLogStream.Name); err != nil { | ||
return err | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,7 @@ func updateLogStreamsAmazonEventBridgeCmd(cli *cli) *cobra.Command { | |
|
||
cmd := &cobra.Command{ | ||
Use: "eventbridge", | ||
Args: cobra.NoArgs, | ||
Args: cobra.MaximumNArgs(1), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bug where we weren't accepting any log stream id for the update command. We fix this here and in other update commands down below. |
||
Short: "Update an existing Amazon Event Bridge log stream", | ||
Long: "Stream real-time Auth0 data to over 15 targets like AWS Lambda.\n\n" + | ||
"To update interactively, use `auth0 logs streams create eventbridge` with no arguments.\n\n" + | ||
|
@@ -124,6 +124,16 @@ func updateLogStreamsAmazonEventBridgeCmd(cli *cli) *cobra.Command { | |
return fmt.Errorf("failed to read log stream with ID %s: %w", inputs.ID, err) | ||
} | ||
|
||
if oldLogStream.GetType() != string(logStreamTypeAmazonEventBridge) { | ||
return fmt.Errorf( | ||
"the log stream with ID %q is of type %q instead of eventbridge, "+ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe use |
||
"use 'auth0 logs streams update %s' to update it instead", | ||
inputs.ID, | ||
oldLogStream.GetType(), | ||
oldLogStream.GetType(), | ||
) | ||
} | ||
|
||
if err := logStreamName.AskU(cmd, &inputs.Name, oldLogStream.Name); err != nil { | ||
return err | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,16 @@ func updateLogStreamsAzureEventGridCmd(cli *cli) *cobra.Command { | |
return fmt.Errorf("failed to read log stream with ID %s: %w", inputs.ID, err) | ||
} | ||
|
||
if oldLogStream.GetType() != string(logStreamTypeAzureEventGrid) { | ||
return fmt.Errorf( | ||
"the log stream with ID %q is of type %q instead of eventgrid, "+ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for the other log types There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in |
||
"use 'auth0 logs streams update %s' to update it instead", | ||
inputs.ID, | ||
oldLogStream.GetType(), | ||
oldLogStream.GetType(), | ||
) | ||
} | ||
|
||
if err := logStreamName.AskU(cmd, &inputs.Name, oldLogStream.Name); err != nil { | ||
return err | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
config: | ||
inherit-env: true | ||
|
||
tests: | ||
001 - it successfully lists all logs: | ||
command: auth0 logs list | ||
exit-code: 0 | ||
stdout: | ||
contains: | ||
- TYPE | ||
- DESCRIPTION | ||
- DATE | ||
- CONNECTION | ||
- CLIENT | ||
|
||
002 - it successfully lists all log streams: | ||
command: auth0 logs streams list | ||
exit-code: 0 | ||
|
||
003 - it successfully creates a datadog log stream: | ||
command: ./test/integration/scripts/create-log-stream-datadog-id.sh | ||
exit-code: 0 | ||
|
||
004 - given a datadog log stream, it successfully gets the log stream's details: | ||
command: auth0 logs streams show $(cat ./test/integration/identifiers/log-stream-datadog-id) | ||
exit-code: 0 | ||
stdout: | ||
contains: | ||
- NAME integration-test-datadog | ||
- TYPE datadog | ||
- STATUS active | ||
|
||
005 - given a datadog log stream, it successfully gets the log stream's details and outputs in json: | ||
command: auth0 logs streams show $(cat ./test/integration/identifiers/log-stream-datadog-id) --json | ||
exit-code: 0 | ||
stdout: | ||
json: | ||
name: "integration-test-datadog" | ||
type: "datadog" | ||
status: "active" | ||
sink.datadogRegion: "eu" | ||
|
||
006 - given a datadog log stream, it successfully updates the log stream's details: | ||
command: auth0 logs streams update datadog $(cat ./test/integration/identifiers/log-stream-datadog-id) --name integration-test-updated-datadog --region us --api-key 123123123123123 --json | ||
exit-code: 0 | ||
stdout: | ||
json: | ||
name: "integration-test-updated-datadog" | ||
type: "datadog" | ||
status: "active" | ||
sink.datadogRegion: "us" | ||
|
||
007 - given a datadog log stream, it successfully opens the log stream's settings page: | ||
command: auth0 logs streams open $(cat ./test/integration/identifiers/log-stream-datadog-id) --no-input | ||
exit-code: 0 | ||
stderr: | ||
contains: | ||
- "Open the following URL in a browser" | ||
|
||
008 - given a datadog log stream, it successfully deletes the log stream: | ||
command: auth0 logs streams delete $(cat ./test/integration/identifiers/log-stream-datadog-id) --force --no-input | ||
exit-code: 0 | ||
|
||
009 - it successfully creates an eventbridge log stream: | ||
command: ./test/integration/scripts/create-log-stream-eventbridge-id.sh | ||
exit-code: 0 | ||
|
||
010 - given an eventbridge log stream, it successfully updates the log stream's details: | ||
command: auth0 logs streams update eventbridge $(cat ./test/integration/identifiers/log-stream-eventbridge-id) --name integration-test-updated-eventbridge --json | ||
exit-code: 0 | ||
stdout: | ||
json: | ||
name: "integration-test-updated-eventbridge" | ||
type: "eventbridge" | ||
status: "active" | ||
|
||
011 - given an eventbridge log stream, it successfully deletes the log stream: | ||
command: auth0 logs streams delete $(cat ./test/integration/identifiers/log-stream-eventbridge-id) --force --no-input | ||
exit-code: 0 | ||
|
||
012 - it successfully creates an http log stream: | ||
command: ./test/integration/scripts/create-log-stream-http-id.sh | ||
exit-code: 0 | ||
|
||
013 - given an http log stream, it successfully updates the log stream's details: | ||
command: auth0 logs streams update http $(cat ./test/integration/identifiers/log-stream-http-id) --name integration-test-updated-http --endpoint "https://example.com/webhook/logs/v2" --format "JSONOBJECT" --json --no-input | ||
exit-code: 0 | ||
stdout: | ||
json: | ||
name: "integration-test-updated-http" | ||
type: "http" | ||
status: "active" | ||
sink.httpContentFormat: "JSONOBJECT" | ||
sink.httpContentType: "application/json" | ||
sink.httpEndpoint: "https://example.com/webhook/logs/v2" | ||
|
||
|
||
014 - given an http log stream, it successfully deletes the log stream: | ||
command: auth0 logs streams delete $(cat ./test/integration/identifiers/log-stream-http-id) --force --no-input | ||
exit-code: 0 | ||
|
||
015 - it successfully creates a splunk log stream: | ||
command: ./test/integration/scripts/create-log-stream-splunk-id.sh | ||
exit-code: 0 | ||
|
||
016 - given a splunk log stream, it successfully updates the log stream's details: | ||
command: auth0 logs streams update splunk $(cat ./test/integration/identifiers/log-stream-splunk-id) --name integration-test-updated-splunk --domain "example.splunk.com" --token "92a34ab5-c6d7-8901-23ef-456b7c89d0c1" --port 8000 --secure --json --no-input | ||
exit-code: 0 | ||
stdout: | ||
json: | ||
name: "integration-test-updated-splunk" | ||
type: "splunk" | ||
status: "active" | ||
sink.splunkDomain: "example.splunk.com" | ||
sink.splunkToken: "92a34ab5-c6d7-8901-23ef-456b7c89d0c1" | ||
sink.splunkPort: "8000" | ||
sink.splunkSecure: "true" | ||
|
||
017 - given a splunk log stream, it successfully deletes the log stream: | ||
command: auth0 logs streams delete $(cat ./test/integration/identifiers/log-stream-splunk-id) --force --no-input | ||
exit-code: 0 | ||
|
||
018 - it successfully creates a sumo log stream: | ||
command: ./test/integration/scripts/create-log-stream-sumo-id.sh | ||
exit-code: 0 | ||
|
||
019 - given a sumo log stream, it successfully updates the log stream's details: | ||
command: auth0 logs streams update sumo $(cat ./test/integration/identifiers/log-stream-sumo-id) --name integration-test-updated-sumo --source "example.sumo.com" --json --no-input | ||
exit-code: 0 | ||
stdout: | ||
json: | ||
name: "integration-test-updated-sumo" | ||
type: "sumo" | ||
status: "active" | ||
sink.sumoSourceAddress: "example.sumo.com" | ||
|
||
020 - given a sumo log stream, it successfully deletes the log stream: | ||
command: auth0 logs streams delete $(cat ./test/integration/identifiers/log-stream-sumo-id) --force --no-input | ||
exit-code: 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#! /bin/bash | ||
|
||
logStream=$( auth0 logs streams create datadog --name integration-test-datadog --region eu --api-key 123233123455 --json --no-input ) | ||
|
||
mkdir -p ./test/integration/identifiers | ||
echo "$logStream" | jq -r '.["id"]' > ./test/integration/identifiers/log-stream-datadog-id |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#! /bin/bash | ||
|
||
logStream=$( auth0 logs streams create eventbridge --name integration-test-eventbridge --aws-id 999999999999 --aws-region eu-west-1 --json --no-input ) | ||
|
||
mkdir -p ./test/integration/identifiers | ||
echo "$logStream" | jq -r '.["id"]' > ./test/integration/identifiers/log-stream-eventbridge-id |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#! /bin/bash | ||
|
||
logStream=$( auth0 logs streams create http --name integration-test-http --endpoint "https://example.com/webhook/logs" --type "application/json" --format "JSONLINES" --json --no-input ) | ||
|
||
mkdir -p ./test/integration/identifiers | ||
echo "$logStream" | jq -r '.["id"]' > ./test/integration/identifiers/log-stream-http-id |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#! /bin/bash | ||
|
||
logStream=$( auth0 logs streams create splunk --name integration-test-splunk --domain "demo.splunk.com" --token "12a34ab5-c6d7-8901-23ef-456b7c89d0c1" --port "8088" --secure --json --no-input ) | ||
|
||
mkdir -p ./test/integration/identifiers | ||
echo "$logStream" | jq -r '.["id"]' > ./test/integration/identifiers/log-stream-splunk-id |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#! /bin/bash | ||
|
||
logStream=$( auth0 logs streams create sumo --name integration-test-sumo --source "demo.sumo.com" --json --no-input ) | ||
|
||
mkdir -p ./test/integration/identifiers | ||
echo "$logStream" | jq -r '.["id"]' > ./test/integration/identifiers/log-stream-sumo-id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We always give command hints in other places, so this just makes things consistent.