Sha256: 8c3b08ccaed67bc4aaee74a9f72ca6d84761bb1e425c61eed07a6bd25338d2a6

Contents?: true

Size: 1.78 KB

Versions: 13

Compression:

Stored size: 1.78 KB

Contents

---
title: About the oracledb_session Resource
---

# oracledb_session

Use the `oracledb_session` InSpec audit resource to test SQL commands run against a Oracle database.

## Syntax

A `oracledb_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 oracledb_session(user: 'username', password: 'password', service: 'ORCL.localdomain').query('QUERY').row(0).column('result') do
      its('value') { should eq('') }
    end

where

* `oracledb_session` declares a username and password with permission to run the query (required), and an optional parameters for host (default: `localhost`), SID (default: `nil`, which uses the default SID, and path to the sqlplus binary (default: `sqlplus`).
* `query('QUERY')` contains the query to be run
* `its('value') { should eq('') }` compares the results of the query against the expected result in the test

## Matchers

This InSpec audit resource has the following matchers:

### cmp

<%= partial "/shared/matcher_cmp" %>

### eq

<%= partial "/shared/matcher_eq" %>

## Examples

The following examples show how to use this InSpec audit resource.

### Test for matching databases

    sql = oracledb_session(user: 'my_user', pass: 'password')

    describe sql.query('SELECT NAME AS VALUE FROM v$database;').row(0).column('value') do
      its('value') { should cmp 'ORCL' }
    end

### Test for matching databases with custom host, SID and sqlplus binary location

    sql = oracledb_session(user: 'my_user', pass: 'password', host: 'oraclehost', sid: 'mysid', sqlplus_bin: '/u01/app/oracle/product/12.1.0/dbhome_1/bin/sqlplus')

    describe sql.query('SELECT NAME FROM v$database;').row(0).column('name') do
      its('value') { should cmp 'ORCL' }
    end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
inspec-1.40.0 docs/resources/oracledb_session.md.erb
inspec-1.39.1 docs/resources/oracledb_session.md.erb
inspec-1.38.8 docs/resources/oracledb_session.md.erb
inspec-1.37.6 docs/resources/oracledb_session.md.erb
inspec-1.36.1 docs/resources/oracledb_session.md.erb
inspec-1.35.1 docs/resources/oracledb_session.md.erb
inspec-1.34.1 docs/resources/oracledb_session.md.erb
inspec-1.33.12 docs/resources/oracledb_session.md.erb
inspec-1.33.1 docs/resources/oracledb_session.md.erb
inspec-1.32.1 docs/resources/oracledb_session.md.erb
inspec-1.31.1 docs/resources/oracledb_session.md.erb
inspec-1.31.0 docs/resources/oracledb_session.md.erb
inspec-1.30.0 docs/resources/oracledb_session.md.erb