223 Commits

Author SHA1 Message Date
Vault Automation
0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:20 -06:00
Vault Automation
7efe8aa99b
Fix seal rewrap running unnecessarily (#9466) (#9895)
Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>
2025-10-07 07:24:17 -04:00
Ryan Cragun
4c3a440e1f
testhelpers(ldap): always time out if we can't start the container in 1 minute (#31509)
Signed-off-by: Ryan Cragun <me@ryan.ec>
2025-08-15 17:35:06 -06:00
Victor Rodriguez
32e3ecbf83
Add hooks for enterprise token auth metadata feature. (#31391) 2025-08-05 12:32:48 -04:00
miagilepner
bea32a14ab
VAULT-35369: Loaded snapshots CE (#30529)
* full load

* snapshot manager tested

* integration test

* more tetsts

* remove obselete test

* fix failing test

* move tesdata to ent folder

* add test for RaftDataDirPath

* fix race condition, don't create new barrier instance

* check for nil result

* remove encryption from the barrier storage wrapper

* Update physical/raft/fsm.go

Co-authored-by: Kuba Wieczorek <kuba.wieczorek@hashicorp.com>

* fmt

---------

Co-authored-by: Kuba Wieczorek <kuba.wieczorek@hashicorp.com>
2025-05-16 14:27:04 +02:00
John-Michael Faircloth
86651479c8
test: fix CompilePlugin test helper (#30644)
This PR fixes CompilePlugin which would fail when run locally in certain
situations based on relative directory paths. This change makes
CompilePlugin perform os.Stat on the full path to the plugin's main.go
file to ensure the test changes to the appropriate directory for
building the plugin.
2025-05-15 20:42:44 +00:00
Ryan Cragun
95b2d86870
ldap: pin test container to latest working version (#30148)
The test container that we use for many LDAP tests recently merged a
breaking change: https://github.com/rroemhild/docker-test-openldap/issues/62

Add support for using containers via references with digests and pin to the latest
version that worked. We can unpin later if so desired.

Signed-off-by: Ryan Cragun <me@ryan.ec>
2025-04-01 22:24:15 +00:00
miagilepner
4f32443722
fixes for flakes in raft removed tests (#29270)
* fixes for flakes in raft removed tests

* one more fix
2025-01-07 13:56:07 +01:00
Steven Clark
7d26c54350
Do not use static certificates for diagnose tests (#29122)
* Do not use static certificates for diagnose tests

* Fix operator command tests, move PKI CA creation code into testhelper lib

* Fix compilation error from refactoring
2024-12-09 14:03:16 +01:00
Scott Miller
86ba0dbdeb
Use go-secure-stdlib's RSA key generator backed by a DRBG (#29020)
* Use DRBG based RSA key generation everywhere

* switch to the conditional generator

* Use DRBG based RSA key generation everywhere

* switch to the conditional generator

* Add an ENV var to disable the DRBG in a pinch

* update go.mod

* Use DRBG based RSA key generation everywhere

* switch to the conditional generator

* Add an ENV var to disable the DRBG in a pinch

* Use DRBG based RSA key generation everywhere

* update go.mod

* fix import

* Remove rsa2 alias, remove test code

* move cryptoutil/rsa.go to sdk

* move imports too

* remove makefile change

* rsa2->rsa

* more rsa2->rsa, remove test code

* fix some overzelous search/replace

* Update to a real tag

* changelog

* copyright

* work around copyright check

* work around copyright check pt2

* bunch of dupe imports

* missing import

* wrong license

* fix go.mod conflict

* missed a spot

* dupe import
2024-12-05 15:39:16 -06:00
Steven Clark
c3d5c1b3ec
Update to Go 1.23.3 (#28920)
* Update to Go 1.23.3

 - Update to latest major version of Go 1.23.3 from 1.22.8.
 - Update github.com/sasha-s/go-deadlock to address deadlock timer
   issue we were seeing.
 - Fix one of our tests to only reset the member variable we change
   instead of the entire Opts parameter to avoid a data race during
   testing.

* Add workaround for MSSQL TLS certificate container issue
2024-11-15 13:32:09 -05:00
miagilepner
10bd15f956
VAULT-30877: Repopulate AWS static creds queue in initialize (#28775)
* populate rotation queue in initialize

* docs, changelog

* add t.Helper()
2024-11-04 09:32:14 -06:00
Steven Clark
6acfc8e212
Add a core test logger to help capture the MSSQL container output (#28472)
* Add a core test logger to help capture the MSSQL container output

 - I believe the if t.Failed prevents the logging of the container
   logging as when executed the test isn't considered failed yet.
 - Use a test core logger so that we can capture the container output
   all the time and get it from the captured log files when the test
   fails

* bump image tag to 2022-latest

---------

Co-authored-by: JM Faircloth <jmfaircloth@hashicorp.com>
2024-09-23 13:57:21 -04:00
Steven Clark
13de053935
Do not shadown err within MSSQL test container intialization (#28468)
- Get better test failure error messages by not shadowing the errors
   when we are attempting to start the MSSQL docker container, so
   we can fail the tests with the proper error message that is occuring
   instead of mssqlhelper.go:60: Could not start docker MSSQL: %!s(<nil>)
2024-09-23 12:22:11 -04:00
vinay-gopalan
ec9b675f70
Add OSS stub functions for Self-Managed Static Roles (#28199) 2024-08-29 10:01:01 -07:00
John-Michael Faircloth
3fcb1a67c5
database/postgres: add inline certificate authentication fields (#28024)
* add inline cert auth to postres db plugin

* handle both sslinline and new TLS plugin fields

* refactor PrepareTestContainerWithSSL

* add tests for postgres inline TLS fields

* changelog

* revert back to errwrap since the middleware sanitizing depends on it

* enable only setting sslrootcert
2024-08-09 14:20:19 -05:00
John-Michael Faircloth
899ebd4aff
db/postgres: add feature flag protected sslinline configuration (#27871)
* adds sslinline option to postgres conn string
* for database secrets type postgres, inspects the connection string for sslinline and generates a tlsconfig from the connection string.

* support fallback hosts

* remove broken multihost test

* bootstrap container with cert material

* overwrite pg config and set key file perms

* add feature flag check

* add tests

* add license and comments

* test all ssl modes

* add test cases for dsn (key/value) connection strings

* add fallback test cases

* fix error formatting

* add test for multi-host when using pgx native conn url parsing

---------

Co-authored-by: Branden Horiuchi <Branden.Horiuchi@blackline.com>
2024-08-01 11:43:54 -05:00
idnandre
e26c246cbb
chore: fix deprecated ioutil readall (#27823)
Signed-off-by: idnandre <andre@idntimes.com>
2024-07-30 09:18:24 -04:00
Violet Hynes
dbecbcec18
VAULT-27384 Fix faulty assignments and unchecked errors (#27810)
* VAULT-27384 Fix faulty assignments and unchecked errors

* Another missed error

* Small refactor
2024-07-22 16:53:02 -04:00
John-Michael Faircloth
d6a588b8d2
db: refactor postgres test helpers (#27811)
* db: refactor postgres test helpers

* fix references to refactored test helper

* fix references to refactored test helper

* fix failing test
2024-07-19 09:47:34 -05:00
Violet Hynes
fd884ad1a0
Removal of go-testing-interface (CE changes) (#27578)
* Removal of go-testing-interface CE changes

* CE only fine

* Changelog

* Changelog
2024-07-04 11:09:41 -04:00
Marc Boudreau
8f26f19950
add retry logic in ldap.PrepareTestContainer (#27617) 2024-07-02 10:47:32 -04:00
Marc Boudreau
30d287edeb
capture docker logs if container creation failed (#27449) 2024-06-13 08:05:01 -04:00
Marc Boudreau
47b7e9d303
capture container logs prior to removing container if the test is failed (#27332) 2024-06-04 11:30:42 -04:00
Victor Rodriguez
bfbc926f0a
Add NewTestLoggerWithSuffix for tests that need multiple log files. (#26879) 2024-05-09 09:46:34 -04:00
Peter Wilson
195fc8333d
Updated comments (#26730) 2024-05-01 12:36:06 +01:00
Victor Rodriguez
e7ea297f8c
Add new func RetryUntilAtCadenceWithHandler to testhelpers.go. (#26611)
* Add new func RetryUntilAtCadenceWithHandler to testhelpers.go.

* Correct godoc comment for RetryUntilAtCadenceWithHandles.

Co-authored-by: Steven Clark <steven.clark@hashicorp.com>

---------

Co-authored-by: Steven Clark <steven.clark@hashicorp.com>
2024-04-24 10:53:46 -04:00
Peter Wilson
8bee54c89d
VAULT-24452: audit refactor (#26460)
* Refactor audit code into audit package
* remove builtin/audit
* removed unrequired files
2024-04-18 08:25:04 +01:00
Christopher Swenson
961bf20bdb
Use enumer to generate String() methods for most enums (#25705)
We have many hand-written String() methods (and similar) for enums.
These require more maintenance and are more error-prone than using
automatically generated methods. In addition, the auto-generated
versions can be more efficient.

Here, we switch to using https://github.com/loggerhead/enumer, itself
a fork of https://github.com/diegostamigni/enumer, no longer maintained,
and a fork of the mostly standard tool
https://pkg.go.dev/golang.org/x/tools/cmd/stringer.
We use this fork of enumer for Go 1.20+ compatibility and because
we require the `-transform` flag to be able to generate
constants that match our current code base.

Some enums were not targeted for this change:
2024-04-17 11:14:14 -07:00
Peter Wilson
38a78697c2
move noop audit to audit package (#26448) 2024-04-16 19:09:11 +01:00
Peter Wilson
3dc16db87e
VAULT-24798: audit - improve error messages (#26312)
* audit: remove 'op' from error messages and do some clean up

* Allow early error checking to be concerned with vault/Core vs. audit
2024-04-11 09:09:32 +01:00
John-Michael Faircloth
f2b5290bc1
ldap/auth: add tests for login regressions (#26327)
* ldap/auth: add tests for login regressions

Add tests to cover the regressions reported in
- https://github.com/hashicorp/vault/issues/26171
- https://github.com/hashicorp/vault/issues/26183

* fix tests; update image tag
2024-04-10 17:39:30 +00:00
Peter Wilson
e0a905e8f8
VAULT-25710: Audit - enforce header formatter requirement in EntryFormatter (#26239)
* Check Enterprise unseal order for audit funcs, enforce header formatter in audit entry formatter node
* ApplyConfig return empty headers (but never nil) when nil/empty supplied
* Add NoopHeaderFormatter and remove builtin audit testHeaderFormatters
2024-04-03 10:53:34 +01:00
Peter Wilson
67c16342d8
VAULT-24013: Audit regression attempting to recover from panic (#25605)
* Add Logger to BackendConfig

* EntryFormatter use logger and recover panics

* Added TODO to consider

* Add 'name' to entry formatter

* Add test for the panic

* Fix NoopAudit with update params

* emit counter metric even when 0

* Fix vault package tests

* changelog

* Remove old comment during test writing
2024-02-26 10:33:30 +00:00
Victor Rodriguez
633dae1a6a
Add event listerner to NoopAudit for audited request assertions. (#25507) 2024-02-19 12:15:57 -05:00
Nick Cabatoff
b5cbc8b986
Add replication.SetCorePerf to create a ReplicationSet using NewTestCluster (#25381) 2024-02-16 09:00:47 -05:00
Josh Black
fa13dbd381
add gosimport to make fmt and run it (#25383)
* add gosimport to make fmt and run it

* move installation to tools.sh

* correct weird spacing issue

* Update Makefile

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>

* fix a weird issue

---------

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>
2024-02-13 14:07:02 -08:00
Nick Cabatoff
1b8606d9ec
Minor improvements to test cluster libraries (#25329)
Add WaitForMatchingMerkleRootsClients and Clients to sdk testcluster.  Fix internal TestCluster.SetRootToken, which wasn't updating the builtin clients' token.
2024-02-09 09:45:43 -05:00
Nick Cabatoff
cadef7b2cd
Fix multi-cluster raft tests that use TCP networking (#24894) 2024-01-16 20:18:08 +00:00
Peter Wilson
ebf627ceed
VAULT-23050: Remove undocumented feature flag to disable audit eventlogger (#24764)
* Work towards removing the feature flag that disabled eventlogger for audit events

* Removed audited headers from LogRequest and LogResponse and clean up

* make clear we don't use a method param, and comment tweak

* Moved BenchmarkAuditFile_request to audit_broker_test and renamed. Clean up

* fixed calls from tests to Factory's

* waffling godoc for a ported and tweaked test

* Remove duplicate code from previous merges, remove uneeded code

* Refactor file audit backend tests

---------

Co-authored-by: Kuba Wieczorek <kuba.wieczorek@hashicorp.com>
2024-01-11 11:30:36 +00:00
Kuba Wieczorek
2047ce7527
[VAULT-22480] Add audit fallback device (#24583)
Co-authored-by: Peter Wilson <peter.wilson@hashicorp.com>
2024-01-08 13:57:43 +00:00
Kuba Wieczorek
17ffe62d0d
[VAULT-22481] Add audit filtering feature (#24558)
* VAULT-22481: Audit filter node (#24465)

* Initial commit on adding filter nodes for audit

* tests for audit filter

* test: longer filter - more conditions

* copywrite headers

* Check interface for the right type

* Add audit filtering feature (#24554)

* Support filter nodes in backend factories and add some tests

* More tests and cleanup

* Attempt to move control of registration for nodes and pipelines to the audit broker (#24505)

* invert control of the pipelines/nodes to the audit broker vs. within each backend

* update noop audit test code to implement the pipeliner interface

* noop mount path has trailing slash

* attempting to make NoopAudit more friendly

* NoopAudit uses known salt

* Refactor audit.ProcessManual to support filter nodes

* HasFiltering

* rename the pipeliner

* use exported AuditEvent in Filter

* Add tests for registering and deregistering backends on the audit broker

* Add missing licence header to one file, fix a typo in two tests

---------

Co-authored-by: Peter Wilson <peter.wilson@hashicorp.com>

* Add changelog file

* update bexpr datum to use a strong type

* go docs updates

* test path

* PR review comments

* handle scenarios/outcomes from broker.send

* don't need to re-check the complete sinks

* add extra check to deregister to ensure that re-registering non-filtered device sets sink threshold

* Ensure that the multierror is appended before attempting to return it

---------

Co-authored-by: Peter Wilson <peter.wilson@hashicorp.com>
2023-12-18 18:01:49 +00:00
Nick Cabatoff
423b58c90b
Simplify raft cluster address management in tests (#24560) 2023-12-18 09:42:23 -05:00
Nick Cabatoff
f460a69ad9
Simplify raft tests, use inmem networking instead of address providers (#24557) 2023-12-15 12:28:32 -05:00
Peter Wilson
24c6e82a84
Remove old audit behavior from test code (#24540)
* Export audit event

* Move older tests away from audit behavior that didn't use eventlogger

* spelling--;

* no more struct initialization of NoopAudit outside of NewNoopAudit

* locking since we're accessing the shared backend
2023-12-15 09:26:34 +00:00
Peter Wilson
486df81934
Audit related foibles (#24493)
* update node and pipeline registration to prevent overwriting, strip some unused bits of NewTestCluster, tweak to prevent auditing on a test that is flaking

* tidy imports
2023-12-13 09:08:02 +00:00
Tom Proctor
a4180c193b
Refactor plugin catalog and plugin runtime catalog into their own package (#24403)
* Refactor plugin catalog into its own package
* Fix some unnecessarily slow tests due to accidentally running multiple plugin processes
* Clean up MakeTestPluginDir helper
* Move getBackendVersion tests to plugin catalog package
* Use corehelpers.MakeTestPlugin consistently
* Fix semgrep failure: check for nil value from logical.Storage
2023-12-07 12:36:17 +00:00
Peter Wilson
7e37f7690d
update testing 'initCores' to enable audit after all unsealing and before enabling KV (#24395) 2023-12-06 12:39:06 +00:00
Steven Clark
b7dff9777d
Allow backends to extract credentials from payloads and trigger an authentication workflow (#23924)
* wip

* Work on the tuneable allowance and some bugs

* Call handleCancellableRequest instead, which gets the audit order more correct and includes the preauth response

* Get rid of no longer needed operation

* Phew, this wasn't necessary

* Add auth error handling by the backend, and fix a bug with handleInvalidCredentials

* Cleanup req/resp naming

* Use the new form, and data

* Discovered that tokens werent really being checked because isLoginRequest returns true for the re-request into the backend, when it shouldnt

* Add a few more checks in the delegated request handler for bad inputs

 - Protect the delegated handler from bad inputs from the backend such
   as an empty accessor, a path that isn't registered as a login request
 - Add similar protections for bad auth results as we do in the normal
   login request paths. Technically not 100% needed but if somehow the
   handleCancelableRequest doesn't use the handleLoginRequest code path
   we could get into trouble in the future
 - Add delegated-auth-accessors flag to the secrets tune command and
   api-docs

* Unit tests and some small fixes

* Remove transit preauth test, rely on unit tests

* Cleanup and add a little more commentary in tests

* Fix typos, add another failure use-case which we reference a disabled auth mount

* PR Feedback

 - Use router to lookup mount instead of defining a new lookup method
 - Enforce auth table types and namespace when mount is found
 - Define a type alias for the handleInvalidCreds
 - Fix typos/grammar
 - Clean up globals in test

* Additional PR feedback

 - Add test for delegated auth handler
 - Force batch token usage
 - Add a test to validate failures if a non-batch token is used
 - Check for Data member being nil in test cases

* Update failure error message around requiring batch tokens

* Trap MFA requests

* Reword some error messages

* Add test and fixes for delegated response wrapping

* Move MFA test to dedicated mount

 - If the delegated auth tests were running in parallel, the MFA test
   case might influence the other tests, so move the MFA to a dedicated
   mount

* PR feedback: use textproto.CanonicalMIMEHeaderKey

 - Change the X-Vault-Wrap-Ttl constant to X-Vault-Wrap-TTL
   and use textproto.CanonicalMIMEHeaderKey to format it
   within the delete call.
 - This protects the code around changes of the constant typing

* PR feedback

 - Append Error to RequestDelegatedAuth
 - Force error interface impl through explicit nil var assignment on
   RequestDelegatedAuthError
 - Clean up test factory and leverage NewTestSoloCluster
 - Leverage newer maps.Clone as this is 1.16 only

---------

Co-authored-by: Scott G. Miller <smiller@hashicorp.com>
2023-11-21 14:36:49 -05:00
Hamid Ghaf
9d3617e567
Revert "Automatically track subloggers in allLoggers (#22038)" (#23986)
This reverts commit 4c8cc87794ed2d989f515cd30c1c1b953d092ef3.
2023-11-03 11:08:01 -07:00