-
Notifications
You must be signed in to change notification settings - Fork 544
feat: Add JSON Schema to Okta source plugin #16493
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
Changes from 2 commits
653be8c
60018cd
c4e1543
f4340d4
9ef33b4
0a35430
e8180cc
98407b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "log" | ||
| "path" | ||
| "runtime" | ||
|
|
||
| "github.com/cloudquery/cloudquery/plugins/source/okta/client" | ||
| cqjsonschema "github.com/cloudquery/codegen/jsonschema" | ||
| ) | ||
|
|
||
| func main() { | ||
| fmt.Println("Generating JSON schema for plugin spec") | ||
| cqjsonschema.GenerateIntoFile(new(client.Spec), path.Join(currDir(), "../..", "schema.json"), | ||
|
candiduslynx marked this conversation as resolved.
|
||
| cqjsonschema.WithAddGoComments("github.com/cloudquery/cloudquery/plugins/source/okta/client", path.Join(currDir(), "../..")), | ||
| ) | ||
| } | ||
|
|
||
| func currDir() string { | ||
| _, filename, _, ok := runtime.Caller(0) | ||
| if !ok { | ||
| log.Fatal("Failed to get caller information") | ||
| } | ||
| return path.Dir(filename) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package client | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/cloudquery/codegen/jsonschema" | ||
| ) | ||
|
|
||
| func TestJSONSchema(t *testing.T) { | ||
| jsonschema.TestJSONSchema(t, JSONSchema, []jsonschema.TestCase{ | ||
| { | ||
| Name: "empty spec", | ||
| Spec: `{}`, | ||
| Err: true, | ||
| }, | ||
| { | ||
| Name: "spec with token", | ||
| Spec: `{"token": "tok"}`, | ||
| Err: true, | ||
| }, | ||
| { | ||
| Name: "spec with token and domain", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com"}`, | ||
| }, | ||
| { | ||
| Name: "spec with token and invalid domain", | ||
| Spec: `{"token": "tok", "domain": "https://<CHANGE_THIS_TO_YOUR_OKTA_DOMAIN>.okta.com"}`, | ||
| Err: true, | ||
| }, | ||
| { | ||
| Name: "spec with token and domain and empty rate limit", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com", "rate_limit": {}}`, | ||
| }, | ||
| { | ||
| Name: "spec with token and domain and null rate limit", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com", "rate_limit": null}`, | ||
| }, | ||
| { | ||
| Name: "spec with token and domain and rate limit", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com", "rate_limit": {"max_backoff": 60}}`, | ||
| }, | ||
| { | ||
| Name: "spec with token and domain and invalid rate limit", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com", "rate_limit": {"max_backoff": true}}`, | ||
|
Contributor
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. remove token from tests (only leave for the tests that are actually testing token)
Contributor
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. Or merge #16498 & reintroduce requirement for |
||
| Err: true, | ||
| }, | ||
| { | ||
| Name: "spec with token and domain and zero rate limit", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com", "rate_limit": {"max_backoff": 0}}`, | ||
|
Contributor
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. rl tests could be extracted into a separate func, see https://github.com/cloudquery/cloudquery/blob/main/plugins/source/aws/client/spec/organization_test.go
Member
Author
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. done in e8180cc |
||
| Err: true, | ||
| }, | ||
| { | ||
| Name: "spec with bool concurrency", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com", "concurrency":false}`, | ||
| Err: true, | ||
| }, | ||
| { | ||
| Name: "spec with null concurrency", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com", "concurrency":null}`, | ||
| Err: true, | ||
| }, | ||
| { | ||
| Name: "spec with string concurrency", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com", "concurrency":"str"}`, | ||
| Err: true, | ||
| }, | ||
| { | ||
| Name: "spec with proper concurrency", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com", "concurrency": 7}`, | ||
| }, | ||
| { | ||
| Name: "spec with array concurrency", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com", "concurrency":["abc"]}`, | ||
| Err: true, | ||
| }, | ||
| { | ||
| Name: "spec with unknown field", | ||
| Spec: `{"token": "tok", "domain": "https://domain.okta.com", "unknown": "test"}`, | ||
| Err: true, | ||
| }, | ||
| }) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.