Skip to content
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
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,11 @@
],
},
{
"name": "SHOW PROVIDERS... ;\" -- prebuilt with cmake",
"name": "SHOW PROVIDERS... ;\" ",
"type": "go",
"request": "launch",
"mode": "exec",
"program": "${workspaceFolder}/build/stackql",
"mode": "debug",
"program": "${workspaceFolder}/stackql",
"args": [
"exec",
"--auth={ \"publicapis\": { \"type\": \"null_auth\" }, \"google\": { \"credentialsfilepath\": \"${workspaceFolder}/keys/sa-key.json\" }, \"okta\": { \"credentialsfilepath\": \"${workspaceFolder}/keys/okta-token.txt\", \"type\": \"api_key\" } }",
Expand Down
19 changes: 1 addition & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,21 @@ module github.com/stackql/stackql
go 1.16

require (
github.com/bketelsen/crypt v0.0.4 // indirect
github.com/coreos/etcd v3.3.13+incompatible // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.13.0
github.com/getkin/kin-openapi v0.88.0
github.com/ghodss/yaml v1.0.0
github.com/go-delve/delve v1.6.1 // indirect
github.com/go-openapi/jsonpointer v0.19.5
github.com/google/go-jsonnet v0.17.0
github.com/magiconair/properties v1.8.5
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/olekukonko/tablewriter v0.0.0-20180130162743-b8a9be070da4
github.com/peterh/liner v1.2.1 // indirect
github.com/pkg/profile v0.0.0-20170413231811-06b906832ed0 // indirect
github.com/prometheus/common v0.9.1
github.com/prometheus/tsdb v0.7.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.3.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.10.1
github.com/stackql/go-openapistackql v0.0.4-alpha46
github.com/stackql/go-openapistackql v0.0.4-alpha55
github.com/stackql/go-sqlite3 v0.0.1-stackqlalpha
go.starlark.net v0.0.0-20210602144842-1cdb82c9e17a // indirect
golang.org/x/arch v0.0.0-20210502124803-cbf565b21d1e // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
golang.org/x/sys v0.0.0-20211210111614-af8b64212486
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0
readline v0.0.0-00010101000000-000000000000
vitess.io/vitess v0.0.9-alpha7
Expand Down
195 changes: 32 additions & 163 deletions go.sum

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions internal/stackql/dto/dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ type AuthCtx struct {
Active bool `json:"-" yaml:"-"`
}

type RegistryCtx struct {
Url string `json:"url" yaml:"url"`
UseEmbedded bool `json:"useEmbedded" yaml:"useEmbedded"`
}

func (ac *AuthCtx) HasKey() bool {
if ac.KeyFilePath != "" || ac.KeyEnvVar != "" {
return true
Expand Down
8 changes: 7 additions & 1 deletion internal/stackql/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package handler
import (
"fmt"
"io"
"path"
"strings"

"github.com/stackql/go-openapistackql/openapistackql"
"github.com/stackql/go-openapistackql/pkg/nomenclature"
Expand Down Expand Up @@ -108,7 +110,11 @@ func getRegistry(runtimeCtx dto.RuntimeCtx) (openapistackql.RegistryAPI, error)
return nil, err
}
if rc.LocalDocRoot == "" {
rc.LocalDocRoot = runtimeCtx.ApplicationFilesRootPath
if strings.HasPrefix(rc.RegistryURL, "file:") {
rc.LocalDocRoot = path.Clean(path.Join(strings.TrimPrefix(rc.RegistryURL, "file:"), ".."))
} else {
rc.LocalDocRoot = runtimeCtx.ApplicationFilesRootPath
}
}
rt := netutils.GetRoundTripper(runtimeCtx, nil)
return openapistackql.NewRegistry(rc, rt)
Expand Down
67 changes: 57 additions & 10 deletions test/functional/stackql_from_cmd_line.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*** Settings ***
Library Process
Library Process
Library OperatingSystem

*** Settings ***
Variables ${CURDIR}/variables/stackql_context.py
Expand All @@ -9,16 +10,62 @@ Positive Control
Should contain '' ''

Get Providers
${result} = Run Process ${STACKQL_EXE} exec \-\-registry\=${REGISTRY_CFG_STR} ${SHOW_PROVIDERS_STR}
Log ${result.stdout}
Should contain ${result.stdout} okta
Should StackQL Exec Contain ${SHOW_PROVIDERS_STR} okta
Should StackQL Embedded Exec Contain ${SHOW_PROVIDERS_STR} okta

Get Okta Services
${result} = Run Process ${STACKQL_EXE} exec \-\-registry\=${REGISTRY_CFG_STR} ${SHOW_OKTA_SERVICES_FILTERED_STR}
Log ${result.stdout}
Should contain ${result.stdout} Application${SPACE}API
Should StackQL Exec Contain ${SHOW_OKTA_SERVICES_FILTERED_STR} Application${SPACE}API
Should StackQL Embedded Exec Contain ${SHOW_OKTA_SERVICES_FILTERED_STR} Application${SPACE}API

Get Okta Application Resources
${result} = Run Process ${STACKQL_EXE} exec \-\-registry\=${REGISTRY_CFG_STR} ${SHOW_OKTA_APPLICATION_RESOURCES_FILTERED_STR}
Log ${result.stdout}
Should contain ${result.stdout} grants groups
Should StackQL Exec Contain ${SHOW_OKTA_APPLICATION_RESOURCES_FILTERED_STR} grants groups
Should StackQL Embedded Exec Contain ${SHOW_OKTA_APPLICATION_RESOURCES_FILTERED_STR} grants groups

*** Keywords ***
Run StackQL Exec Command
[Arguments] ${_EXEC_CMD_STR} @{varargs}
Set Environment Variable OKTA_SECRET_KEY ${OKTA_SECRET_STR}
${result} = Run Process
... ${STACKQL_EXE}
... exec \-\-registry\=${REGISTRY_NO_VERIFY_CFG_STR}
... \-\-auth\=${AUTH_CFG_STR}
... \-\-tls.allowInsecure\=true
... ${_EXEC_CMD_STR} @{varargs}
Log ${result.stdout}
Log ${result.stderr}
[Return] ${result}

Run StackQL Embedded Exec Command
[Arguments] ${_EXEC_CMD_STR} @{varargs}
Set Environment Variable OKTA_SECRET_KEY ${OKTA_SECRET_STR}
${result} = Run Process
... ${STACKQL_EXE}
... exec \-\-registry\=${REGISTRY_EMBEDDED_CFG_STR}
... \-\-auth\=${AUTH_CFG_STR}
... \-\-tls.allowInsecure\=true
... ${_EXEC_CMD_STR} @{varargs}
Log ${result.stdout}
Log ${result.stderr}
[Return] ${result}


Should StackQL Exec Equal
[Arguments] ${_EXEC_CMD_STR} ${_EXEC_CMD_EXPECTED_OUTPUT} @{varargs}
${result} = Run StackQL Exec Command ${_EXEC_CMD_STR} @{varargs}
Should Be Equal ${result.stdout} ${_EXEC_CMD_EXPECTED_OUTPUT}

Should StackQL Embedded Exec Equal
[Arguments] ${_EXEC_CMD_STR} ${_EXEC_CMD_EXPECTED_OUTPUT} @{varargs}
${result} = Run StackQL Embedded Exec Command ${_EXEC_CMD_STR} @{varargs}
Should Be Equal ${result.stdout} ${_EXEC_CMD_EXPECTED_OUTPUT}

Should StackQL Exec Contain
[Arguments] ${_EXEC_CMD_STR} ${_EXEC_CMD_EXPECTED_OUTPUT} @{varargs}
${result} = Run StackQL Exec Command ${_EXEC_CMD_STR}
Should contain ${result.stdout} ${_EXEC_CMD_EXPECTED_OUTPUT} @{varargs}

Should StackQL Embedded Exec Contain
[Arguments] ${_EXEC_CMD_STR} ${_EXEC_CMD_EXPECTED_OUTPUT} @{varargs}
${result} = Run StackQL Embedded Exec Command ${_EXEC_CMD_STR}
Should contain ${result.stdout} ${_EXEC_CMD_EXPECTED_OUTPUT} @{varargs}

2 changes: 1 addition & 1 deletion test/functional/stackql_mocked_from_cmd_line.robot
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Run StackQL Exec Command
Set Environment Variable OKTA_SECRET_KEY ${OKTA_SECRET_STR}
${result} = Run Process
... ${STACKQL_EXE}
... exec \-\-registry\=${REGISTRY_CFG_STR}
... exec \-\-registry\=${REGISTRY_NO_VERIFY_CFG_STR}
... \-\-auth\=${AUTH_CFG_STR}
... \-\-tls.allowInsecure\=true
... ${_EXEC_CMD_STR} @{varargs}
Expand Down
20 changes: 15 additions & 5 deletions test/functional/variables/stackql_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ def get_unix_path(pathStr :str) -> str:


REPOSITORY_ROOT_UNIX = get_unix_path(REPOSITORY_ROOT)
REGISTRY_ROOT = get_unix_path(os.path.join(REPOSITORY_ROOT, 'test', 'registry-mocked'))
REGISTRY_ROOT_MOCKED = get_unix_path(os.path.join(REPOSITORY_ROOT, 'test', 'registry-mocked'))
REGISTRY_ROOT_EMBEDDED = get_unix_path(os.path.join(REPOSITORY_ROOT, 'test', 'registry-embedded-decompressed'))
STACKQL_EXE = get_unix_path(os.path.join(REPOSITORY_ROOT, 'build', _exe_name))
_REGISTRY_CFG = {
"url": f"file://{get_unix_path(REGISTRY_ROOT)}",
"localDocRoot": f"{get_unix_path(REGISTRY_ROOT)}",
_REGISTRY_NO_VERIFY_CFG = {
"url": f"file://{get_unix_path(REGISTRY_ROOT_MOCKED)}",
"localDocRoot": f"{get_unix_path(REGISTRY_ROOT_MOCKED)}",
"useEmbedded": False,
"verifyConfig": {
"nopVerify": True
}
}
_REGISTRY_EMBEDDED_CFG = {
"url": f"file://{get_unix_path(REGISTRY_ROOT_EMBEDDED)}",
"localDocRoot": f"{get_unix_path(REGISTRY_ROOT_EMBEDDED)}",
"useEmbedded": True,
"verifyConfig": {
"nopVerify": False
}
}
_AUTH_CFG={
"google": {
"credentialsfilepath": get_unix_path(os.path.join(REPOSITORY_ROOT, 'test', 'assets', 'credentials', 'dummy', 'google', 'functional-test-dummy-sa-key.json')),
Expand All @@ -42,7 +51,8 @@ def get_unix_path(pathStr :str) -> str:
with open(os.path.join(REPOSITORY_ROOT, 'test', 'assets', 'credentials', 'dummy', 'okta', 'api-key.txt'), 'r') as f:
OKTA_SECRET_STR = f.read()

REGISTRY_CFG_STR = json.dumps(_REGISTRY_CFG)
REGISTRY_NO_VERIFY_CFG_STR = json.dumps(_REGISTRY_NO_VERIFY_CFG)
REGISTRY_EMBEDDED_CFG_STR = json.dumps(_REGISTRY_EMBEDDED_CFG)
AUTH_CFG_STR = json.dumps(_AUTH_CFG)
SHOW_PROVIDERS_STR = "show providers;"
SHOW_OKTA_SERVICES_FILTERED_STR = "show services from okta like 'app%';"
Expand Down
2 changes: 2 additions & 0 deletions test/registry-embedded-decompressed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore