inspec/docs/resources/oracle_session.md.erb
Nolan Davidson 9cd69ce4af Add an oracle_session resource
This adds an oracle_session resource similar to the existing resource
for MySQL and MSSQL.  It assumes the sqlplus tool is installed and in
the path of the user InSpec connects as.

Signed-off-by: Nolan Davidson <ndavidson@chef.io>
2017-05-02 10:50:20 -04:00

63 lines
1.5 KiB
Text

---
title: About the oracle_session Resource
---
# oracle_session
Use the `oracle_session` InSpec audit resource to test SQL commands run against a Oracle database.
## Syntax
A `oracle_session` resource block declares the username and password to use for the session with an optional service to connect to, and then the command to be run:
describe oracle_session('username', 'password').query('QUERY') do
its('output') { should eq('') }
end
where
* `oracle_session` declares a username and password with permission to run the query, and an optional service name. If none is specifed, it will use the default service on the instance.
* `query('QUERY')` contains the query to be run
* `its('output') { should eq('') }` compares the results of the query against the expected result in the test
## Matchers
This InSpec audit resource has the following matchers:
### be
<%= partial "/shared/matcher_be" %>
### cmp
<%= partial "/shared/matcher_cmp" %>
### eq
<%= partial "/shared/matcher_eq" %>
### include
<%= partial "/shared/matcher_include" %>
### match
<%= partial "/shared/matcher_match" %>
### output
The `output` matcher tests the results of the query:
its('output') { should eq(/^0/) }
## Examples
The following examples show how to use this InSpec audit resource.
### Test for matching databases
sql = oracle_session('my_user','password')
describe sql.query('SELECT NAME FROM v$database;') do
its('stdout') { should_not match(/test/) }
end