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 test support for file parameters #2356

Merged
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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-01-19 00:00:01.299640",
"spec_repo_commit": "7dba000a"
"regenerated": "2024-01-19 15:18:10.694664",
"spec_repo_commit": "b407748b"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-01-19 00:00:01.331313",
"spec_repo_commit": "7dba000a"
"regenerated": "2024-01-19 15:18:10.709452",
"spec_repo_commit": "b407748b"
}
}
}
2 changes: 1 addition & 1 deletion tests/scenarios/features/v2/organizations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: Organizations
When the request is sent
Then the response status is 400 Bad Request

@skip-go @skip-java @skip-python @skip-ruby @skip-terraform-config @skip-typescript @skip-validation @team:DataDog/team-aaa-identity
@integration-only @skip-terraform-config @skip-validation @team:DataDog/team-aaa-identity
Scenario: Upload IdP metadata returns "OK" response
Given request contains "idp_file" parameter with value "fixtures/organizations/saml_configurations/valid_idp_metadata.xml"
When the request is sent
Expand Down
21 changes: 18 additions & 3 deletions tests/scenarios/step_definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package scenarios
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
"reflect"
Expand Down Expand Up @@ -171,9 +172,23 @@ func addPathArgumentWithValue(t gobdd.StepTest, ctx gobdd.Context, param string,
}

if varType.IsValid() {
datadog.Unmarshal([]byte(templatedValue), varType.Interface())
GetRequestParameters(ctx)[param] = varType.Elem()
ctx.Set(requestArgsKey{}, append(GetRequestArguments(ctx), varType.Elem()))
switch varType.Interface().(type) {
case *io.Reader:
version := GetVersion(ctx)
var basePath string
datadog.Unmarshal([]byte(templatedValue), &basePath)
filepath := fmt.Sprintf("./features/%s/%s", version, basePath)
fp, err := os.Open(filepath)
if err != nil {
t.Error(err)
}
GetRequestParameters(ctx)[param] = reflect.ValueOf(fp)
ctx.Set(requestArgsKey{}, append(GetRequestArguments(ctx), reflect.ValueOf(fp)))
default:
datadog.Unmarshal([]byte(templatedValue), varType.Interface())
GetRequestParameters(ctx)[param] = varType.Elem()
ctx.Set(requestArgsKey{}, append(GetRequestArguments(ctx), varType.Elem()))
}
} else {
GetRequestParameters(ctx)[param] = reflect.ValueOf(templatedValue)
ctx.Set(requestArgsKey{}, append(GetRequestArguments(ctx), reflect.ValueOf(templatedValue)))
Expand Down
Loading