Skip to content

Commit

Permalink
tests complete
Browse files Browse the repository at this point in the history
  • Loading branch information
subroseio committed Nov 23, 2023
1 parent 8b7305b commit ac58599
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
7 changes: 3 additions & 4 deletions api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ type ErrorResponse struct {
}

func ValidateResourceName(fl validator.FieldLevel) bool {
// Validation for vault internal resource names
reg := "^[a-zA-Z0-9._-]{1,249}$"
reg := "^[a-zA-Z0-9._]{1,249}$"
match, _ := regexp.MatchString(reg, fl.Field().String())

// Check for prohibited values: single period and double underscore
if fl.Field().String() == "." || fl.Field().String() == "__" {
// Check for prohibited values: single period, double underscore, and hyphen
if fl.Field().String() == "." || fl.Field().String() == "__" || fl.Field().String() == "-" {
return false
}

Expand Down
13 changes: 13 additions & 0 deletions simulator/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ def create_collection(
)
check_expected_status(response, expected_statuses)

def update_collection(
self,
collection: str,
schema: dict[str, Any],
expected_statuses: Optional[list[int]] = None,
) -> None:
response = requests.put(
f"{self.vault_url}/collections/{collection}",
json=schema,
auth=(self.username, self.password),
)
check_expected_status(response, expected_statuses)

def create_records(
self,
collection: str,
Expand Down
6 changes: 1 addition & 5 deletions simulator/simulate.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/bin/bash

# redis-cli -h keydb FLUSHALL || exit 1
python ecommerce.py || exit 1

# redis-cli -h keydb FLUSHALL || exit 1
python pci.py || exit 1

# redis-cli -h keydb FLUSHALL || exit 1
python password_manager.py || exit 1
python ops.py || exit 1
8 changes: 4 additions & 4 deletions vault/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ func NewSqlStore(dsn string) (*SqlStore, error) {
func (st *SqlStore) CreateSchemas() error {
tables := map[string]string{
"principals": "CREATE TABLE IF NOT EXISTS principals (username TEXT PRIMARY KEY, password TEXT, description TEXT)",
"policies": "CREATE TABLE IF NOT EXISTS policies (id TEXT, effect TEXT, actions TEXT[], resources TEXT[])",
"principal_policies": "CREATE TABLE IF NOT EXISTS principal_policies (username TEXT, policy_id TEXT)",
"tokens": "CREATE TABLE IF NOT EXISTS tokens (id TEXT, value TEXT)",
"collection_metadata": "CREATE TABLE IF NOT EXISTS collection_metadata (name TEXT, field_schema JSON)",
"policies": "CREATE TABLE IF NOT EXISTS policies (id TEXT PRIMARY KEY, effect TEXT, actions TEXT[], resources TEXT[])",
"principal_policies": "CREATE TABLE IF NOT EXISTS principal_policies (username TEXT, policy_id TEXT, UNIQUE(username, policy_id))",
"tokens": "CREATE TABLE IF NOT EXISTS tokens (id TEXT PRIMARY KEY, value TEXT)",
"collection_metadata": "CREATE TABLE IF NOT EXISTS collection_metadata (name TEXT PRIMARY KEY, field_schema JSON)",
}

for _, query := range tables {
Expand Down

0 comments on commit ac58599

Please sign in to comment.