mirror of
https://github.com/strongdm/comply
synced 2024-11-25 09:04:54 +00:00
Add tests to procedures, policies and standards (#48)
This commit is contained in:
parent
ad2c89ec67
commit
76fb5ec31a
57
fixtures/policies/invalid-access.md
Normal file
57
fixtures/policies/invalid-access.md
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
name: Access Onboarding and Termination Policy
|
||||||
|
acronym: AOTP
|
||||||
|
satisfies:
|
||||||
|
TSC:
|
||||||
|
- CC6.1
|
||||||
|
- CC6.2
|
||||||
|
- CC6.3
|
||||||
|
majorRevisions:
|
||||||
|
- date: Jun 1 2018
|
||||||
|
comment: Initial document
|
||||||
|
---
|
||||||
|
# Purpose and Scope
|
||||||
|
|
||||||
|
a. The purpose of this policy is to define procedures to onboard and offboard users to technical infrastructure in a manner that minimizes the risk of information loss or exposure.
|
||||||
|
|
||||||
|
a. This policy applies to all technical infrastructure within the organization.
|
||||||
|
|
||||||
|
a. This policy applies to all full-time and part-time employees and contractors.
|
||||||
|
|
||||||
|
# Background
|
||||||
|
|
||||||
|
a. In order to minimize the risk of information loss or exposure (from both inside and outside the organization), the organization is reliant on the principle of least privilege. Account creation and permission levels are restricted to only the resources absolutely needed to perform each person’s job duties. When a user’s role within the organization changes, those accounts and permission levels are changed/revoked to fit the new role and disabled when the user leaves the organization altogether.
|
||||||
|
|
||||||
|
# Policy
|
||||||
|
|
||||||
|
a. *During onboarding:*
|
||||||
|
|
||||||
|
i. Hiring Manager informs HR upon hire of a new employee.
|
||||||
|
|
||||||
|
i. HR emails IT to inform them of a new hire and their role.
|
||||||
|
|
||||||
|
i. IT creates a checklist of accounts and permission levels needed for that role.
|
||||||
|
|
||||||
|
i. The owner of each resource reviews and approves account creation and the
|
||||||
|
associated permissions.
|
||||||
|
|
||||||
|
i. IT works with the owner of each resource to set up the user.
|
||||||
|
|
||||||
|
a. *During offboarding:*
|
||||||
|
|
||||||
|
i. Hiring Manager notifies HR when an employee has been terminated.
|
||||||
|
|
||||||
|
i. HR sends a weekly email report to IT summarizing list of users terminated and instructs IT to disable their access.
|
||||||
|
|
||||||
|
i. IT terminates access within five business days from receipt of notification.
|
||||||
|
|
||||||
|
a. *When an employee changes roles within the organization:*
|
||||||
|
|
||||||
|
i. Hiring Manager will inform HR of a change in role.
|
||||||
|
|
||||||
|
i. HR and IT will follow the same steps as outlined in the onboarding and offboarding procedures.
|
||||||
|
|
||||||
|
a. *Review of accounts and permissions:*
|
||||||
|
|
||||||
|
i. Each month, IT and HR will review accounts and permission levels for accuracy.
|
||||||
|
|
||||||
|
|
39
fixtures/procedures/invalid-workstation.md
Normal file
39
fixtures/procedures/invalid-workstation.md
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
id: "workstation"
|
||||||
|
name: "Collect Workstation Details"cron: "0 0 0 15 4 *"
|
||||||
|
---
|
||||||
|
|
||||||
|
Resolve this ticket by executing the following steps:
|
||||||
|
|
||||||
|
- [ ] Send the communications below
|
||||||
|
- [ ] For any email replies, attach content to this ticket
|
||||||
|
- [ ] Validate responses are received from each
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
To: Desktop support
|
||||||
|
Subject: Annual workstation inventory
|
||||||
|
|
||||||
|
Please attach the current workstation inventory to the following ticket: [REPLACE WITH URL TO THIS TICKET]
|
||||||
|
|
||||||
|
The workstation inventory shall include the following fields:
|
||||||
|
* Serial number
|
||||||
|
* Custodian
|
||||||
|
* Full disk encryption status
|
||||||
|
* Malware protection status
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
To: Outsourced Call Center IT
|
||||||
|
Subject: Annual workstation inventory
|
||||||
|
|
||||||
|
As part of our ongoing compliance efforts and per our services agreement, we require a current inventory of workstations in use in the service of our account.
|
||||||
|
|
||||||
|
Please respond to this message with the current inventory.
|
||||||
|
|
||||||
|
The workstation inventory shall include the following fields:
|
||||||
|
* Serial number
|
||||||
|
* Custodian
|
||||||
|
* Full disk encryption status
|
||||||
|
* Malware protection status
|
||||||
|
```
|
245
fixtures/standards/invalid-standard.yml
Normal file
245
fixtures/standards/invalid-standard.yml
Normal file
@ -0,0 +1,245 @@
|
|||||||
|
name: TSC
|
||||||
|
***CC1.1:
|
||||||
|
family: CC1
|
||||||
|
name: Integrity and Ethics
|
||||||
|
description: The entity demonstrates a commitment to integrity and ethical values
|
||||||
|
CC1.2:
|
||||||
|
family: CC1
|
||||||
|
name: Board Independence
|
||||||
|
description: The board of directors demonstrates independence from management and exercises oversight of the development and performance of internal control
|
||||||
|
CC1.3:
|
||||||
|
family: CC1
|
||||||
|
name: Organizational Structure
|
||||||
|
description: Management establishes, with board oversight, structures, reporting lines, and appropriate authorities and responsibilities in the pursuit of objectives
|
||||||
|
CC1.4:
|
||||||
|
family: CC1
|
||||||
|
name: Hiring, Training and Retention
|
||||||
|
description: The entity demonstrates a commitment to attract, develop, and retain competent individuals in alignment with objectives
|
||||||
|
CC1.5:
|
||||||
|
family: CC1
|
||||||
|
name: Individual Accountability
|
||||||
|
description: The entity holds individuals accountable for their internal control responsibilities in the pursuit of objectives.
|
||||||
|
CC2.1:
|
||||||
|
family: CC2
|
||||||
|
name: Use of Information Systems
|
||||||
|
description: The entity obtains or generates and uses relevant, quality information to support the functioning of internal control
|
||||||
|
CC2.2:
|
||||||
|
family: CC2
|
||||||
|
name: Use of Communication Systems, Internal
|
||||||
|
description: The entity internally communicates information, including objectives and responsibilities for internal control, necessary to support the functioning of internal control
|
||||||
|
CC2.3:
|
||||||
|
family: CC2
|
||||||
|
name: Use of Communication Systems, External
|
||||||
|
description: The entity communicates with external parties regarding matters affecting the functioning of internal control
|
||||||
|
CC3.1:
|
||||||
|
family: CC3
|
||||||
|
name: Objectives
|
||||||
|
description: The entity specifies objectives with sufficient clarity to enable the identification and assessment of risks relating to objectives
|
||||||
|
CC3.2:
|
||||||
|
family: CC3
|
||||||
|
name: Risk to Objectives
|
||||||
|
description: The entity identifies risks to the achievement of its objectives across the entity and analyzes risks as a basis for determining how the risks should be managed
|
||||||
|
CC3.3:
|
||||||
|
family: CC3
|
||||||
|
name: Fraud Risk to Objectives
|
||||||
|
description: The entity considers the potential for fraud in assessing risks to the achievement of objectives
|
||||||
|
CC3.4:
|
||||||
|
family: CC3
|
||||||
|
name: Impact of Changes
|
||||||
|
description: The entity identifies and assesses changes that could significantly impact the system of internal control
|
||||||
|
CC4.1:
|
||||||
|
family: CC4
|
||||||
|
name: Monitoring
|
||||||
|
description: The entity selects, develops, and performs ongoing and/or separate evaluations to ascertain whether the components of internal control are present and functioning
|
||||||
|
CC4.2:
|
||||||
|
family: CC4
|
||||||
|
name: Remediation
|
||||||
|
description: The entity evaluates and communicates internal control deficiencies in a timely manner to those parties responsible for taking corrective action, including senior management and the board of directors, as appropriate
|
||||||
|
CC5.1:
|
||||||
|
family: CC5
|
||||||
|
name: Objective Risk Mitigation
|
||||||
|
description: The entity selects and develops control activities that contribute to the mitigation of risks to the achievement of objectives to acceptable levels
|
||||||
|
CC5.2:
|
||||||
|
family: CC5
|
||||||
|
name: Technology Controls
|
||||||
|
description: The entity also selects and develops general control activities over technology to support the achievement of objectives
|
||||||
|
CC5.3:
|
||||||
|
family: CC5
|
||||||
|
name: Established Policies
|
||||||
|
description: The entity deploys control activities through policies that establish what is expected and in procedures that put policies into action
|
||||||
|
CC6.1:
|
||||||
|
family: CC6
|
||||||
|
name: Logical Access
|
||||||
|
description: The entity implements logical access security software, infrastructure, and architectures over protected information assets to protect them from security events to meet the entity’s objectives
|
||||||
|
CC6.2:
|
||||||
|
family: CC6
|
||||||
|
name: User Access
|
||||||
|
description: Prior to issuing system credentials and granting system access, the entity registers and authorizes new internal and external users whose access is administered by the entity. For those users whose access is administered by the entity, user system credentials are removed when user access is no longer authorized
|
||||||
|
CC6.3:
|
||||||
|
family: CC6
|
||||||
|
name: Role-Based Access
|
||||||
|
description: The entity authorizes, modifies, or removes access to data, software, functions, and other protected information assets based on roles, responsibilities, or the system design and changes, giving consideration to the concepts of least privilege and segregation of duties, to meet the entity’s objectives
|
||||||
|
CC6.4:
|
||||||
|
family: CC6
|
||||||
|
name: Physical Access
|
||||||
|
description: The entity restricts physical access to facilities and protected information assets (for example, data center facilities, back-up media storage, and other sensitive locations) to authorized personnel to meet the entity’s objectives
|
||||||
|
CC6.5:
|
||||||
|
family: CC6
|
||||||
|
name: Data Disposal
|
||||||
|
description: The entity discontinues logical and physical protections over physical assets only after the ability to read or recover data and software from those assets has been diminished and is no longer required to meet the entity’s objectives
|
||||||
|
CC6.6:
|
||||||
|
family: CC6
|
||||||
|
name: External Threats
|
||||||
|
description: The entity implements logical access security measures to protect against threats from sources outside its system boundaries
|
||||||
|
CC6.7:
|
||||||
|
family: CC6
|
||||||
|
name: Data Custody and Transmission
|
||||||
|
description: The entity restricts the transmission, movement, and removal of information to authorized internal and external users and processes, and protects it during transmission, movement, or removal to meet the entity’s objectives
|
||||||
|
CC6.8:
|
||||||
|
family: CC6
|
||||||
|
name: Malware Detection
|
||||||
|
description: The entity implements controls to prevent or detect and act upon the introduction of unauthorized or malicious software to meet the entity’s objectives
|
||||||
|
CC7.1:
|
||||||
|
family: CC7
|
||||||
|
name: Vulnerability Detection
|
||||||
|
description: To meet its objectives, the entity uses detection and monitoring procedures to identify (1) changes to configurations that result in the introduction of new vulnerabilities, and (2) susceptibilities to newly discovered vulnerabilities
|
||||||
|
CC7.2:
|
||||||
|
family: CC7
|
||||||
|
name: Anomaly Detection
|
||||||
|
description: The entity monitors system components and the operation of those components for anomalies that are indicative of malicious acts, natural disasters, and errors affecting the entity’s ability to meet its objectives; anomalies are analyzed to determine whether they represent security events
|
||||||
|
CC7.3:
|
||||||
|
family: CC7
|
||||||
|
name: Security Incident Evaluation
|
||||||
|
description: The entity evaluates security events to determine whether they could or have resulted in a failure of the entity to meet its objectives (security incidents) and, if so, takes actions to prevent or address such failures
|
||||||
|
CC7.4:
|
||||||
|
family: CC7
|
||||||
|
name: Security Incident Response Plan
|
||||||
|
description: The entity responds to identified security incidents by executing a defined incident response program to understand, contain, remediate, and communicate security incidents, as appropriate
|
||||||
|
CC7.5:
|
||||||
|
family: CC7
|
||||||
|
name: Security Incident Response Execution
|
||||||
|
description: The entity identifies, develops, and implements activities to recover from identified security incidents
|
||||||
|
CC8.1:
|
||||||
|
family: CC8
|
||||||
|
name: Change Control
|
||||||
|
description: The entity authorizes, designs, develops or acquires, configures, documents, tests, approves, and implements changes to infrastructure, data, software, and procedures to meet its objectives
|
||||||
|
CC9.1:
|
||||||
|
family: CC9
|
||||||
|
name: Disruption Risk Mitigation
|
||||||
|
description: The entity identifies, selects, and develops risk mitigation activities for risks arising from potential business disruptions
|
||||||
|
CC9.2:
|
||||||
|
family: CC9
|
||||||
|
name: Vendor Risk Management
|
||||||
|
description: The entity assesses and manages risks associated with vendors and business partners
|
||||||
|
A1.1:
|
||||||
|
family: A1
|
||||||
|
name: Capacity Planning
|
||||||
|
description: The entity maintains, monitors, and evaluates current processing capacity and use of system components (infrastructure, data, and software) to manage capacity demand and to enable the implementation of additional capacity to help meet its objectives
|
||||||
|
A1.2:
|
||||||
|
family: A1
|
||||||
|
name: Backup and Recovery
|
||||||
|
description: The entity authorizes, designs, develops or acquires, implements, operates, approves, maintains, and monitors environmental protections, software, data back-up processes, and recovery infrastructure to meet its objectives
|
||||||
|
A1.3:
|
||||||
|
family: A1
|
||||||
|
name: Recovery Testing
|
||||||
|
description: The entity tests recovery plan procedures supporting system recovery to meet its objectives
|
||||||
|
C1.1:
|
||||||
|
family: C1
|
||||||
|
name: Confidential Information Identification
|
||||||
|
description: The entity identifies and maintains confidential information to meet the entity’s objectives related to confidentiality
|
||||||
|
C1.2:
|
||||||
|
family: C1
|
||||||
|
name: Confidential Information Disposal
|
||||||
|
description: The entity disposes of confidential information to meet the entity’s objectives related to confidentiality.
|
||||||
|
PI1.1:
|
||||||
|
family: PI1
|
||||||
|
name: Processing Integrity Monitoring
|
||||||
|
description: The entity obtains or generates, uses, and communicates relevant, quality information regarding the objectives related to processing, including definitions of data processed and product and service speci cations, to support the use of products and services
|
||||||
|
PI1.2:
|
||||||
|
family: PI1
|
||||||
|
name: Processing Integrity Accuracy
|
||||||
|
description: The entity implements policies and procedures over system inputs, including controls over completeness and accuracy, to result in products, services, and reporting to meet the entity’s objectives
|
||||||
|
PI1.3:
|
||||||
|
family: PI1
|
||||||
|
name: Processing Integrity Operations
|
||||||
|
description: The entity implements policies and procedures over system processing to result in products, services, and reporting to meet the entity’s objectives
|
||||||
|
PI1.4:
|
||||||
|
family: PI1
|
||||||
|
name: Processing Integrity Outputs
|
||||||
|
description: The entity implements policies and procedures to make available or deliver output completely, accurately, and timely in accordance with specifications to meet the entity’s objectives
|
||||||
|
PI1.5:
|
||||||
|
family: PI1
|
||||||
|
name: Processing Integrity Backups
|
||||||
|
description: The entity implements policies and procedures to store inputs, items in processing, and outputs completely, accurately, and timely in accordance with system specifications to meet the entity’s objectives
|
||||||
|
P1.1:
|
||||||
|
family: P1
|
||||||
|
name: Privacy Notification
|
||||||
|
description: The entity provides notice to data subjects about its privacy practices to meet the entity’s objectives related to privacy. The notice is updated and communicated to data subjects in a timely manner for changes to the entity’s privacy practices, including changes in the use of personal information, to meet the entity’s objectives related to privacy
|
||||||
|
P2.1:
|
||||||
|
family: P2
|
||||||
|
name: Privacy Consent and Choice
|
||||||
|
description: The entity communicates choices available regarding the collection, use, retention, disclosure, and disposal of personal information to the data subjects and the consequences, if any, of each choice. Explicit consent for the collection, use, retention, disclosure, and disposal of personal information is obtained from data subjects or other authorized persons, if required. Such consent is obtained only for the intended purpose of the information to meet the entity’s objectives related to privacy. The entity’s basis for determining implicit consent for the collection, use, retention, disclosure, and disposal of personal information is documented
|
||||||
|
P3.1:
|
||||||
|
family: P3
|
||||||
|
name: Personal Information Collection
|
||||||
|
description: Personal information is collected consistent with the entity’s objectives related to privacy
|
||||||
|
P3.2:
|
||||||
|
family: P3
|
||||||
|
name: Explicit Consent
|
||||||
|
description: For information requiring explicit consent, the entity communicates the need for such consent, as well as the consequences of a failure to provide consent for the request for personal information, and obtains the consent prior to the collection of the information to meet the entity’s objectives related to privacy
|
||||||
|
P4.1:
|
||||||
|
family: P4
|
||||||
|
name: Proper Use of Personal Information
|
||||||
|
description: The entity limits the use of personal information to the purposes identified in the entity’s objectives related to privacy
|
||||||
|
P4.2:
|
||||||
|
family: P4
|
||||||
|
name: Personal Information Retention
|
||||||
|
description: The entity retains personal information consistent with the entity’s objectives related to privacy
|
||||||
|
P4.3:
|
||||||
|
family: P4
|
||||||
|
name: Personal Information Disposal
|
||||||
|
description: The entity securely disposes of personal information to meet the entity’s objectives related to privacy
|
||||||
|
P5.1:
|
||||||
|
family: P5
|
||||||
|
name: Data Subject Access
|
||||||
|
description: The entity grants identified and authenticated data subjects the ability to access their stored personal information for review and, upon request, provides physical or electronic copies of that information to data subjects to meet the entity’s objectives related to privacy. If access is denied, data subjects are informed of the denial and reason for such denial, as required, to meet the entity’s objectives related to privacy
|
||||||
|
P5.2:
|
||||||
|
family: P5
|
||||||
|
name: Data Subject Amendment
|
||||||
|
description: The entity corrects, amends, or appends personal information based on information provided by data subjects and communicates such information to third parties, as committed or required, to meet the entity’s objectives related to privacy. If a request for correction is denied, data subjects are informed of the denial and reason for such denial to meet the entity’s objectives related to privacy
|
||||||
|
P6.1:
|
||||||
|
family: P6
|
||||||
|
name: Consent for Third Party Disclosure
|
||||||
|
description: The entity discloses personal information to third parties with the explicit consent of data subjects, and such consent is obtained prior to disclosure to meet the entity’s objectives related to privacy
|
||||||
|
P6.2:
|
||||||
|
family: P6
|
||||||
|
name: Authorized Disclosures
|
||||||
|
description: The entity creates and retains a complete, accurate, and timely record of authorized disclosures of personal information to meet the entity’s objectives related to privacy
|
||||||
|
P6.3:
|
||||||
|
family: P6
|
||||||
|
name: Unauthorized Disclosures
|
||||||
|
description: The entity creates and retains a complete, accurate, and timely record of detected or reported unauthorized disclosures (including breaches) of personal information to meet the entity’s objectives related to privacy
|
||||||
|
P6.4:
|
||||||
|
family: P6
|
||||||
|
name: Appropriate Third Party Disclosure
|
||||||
|
description: The entity obtains privacy commitments from vendors and other third parties who have access to personal information to meet the entity’s objectives related to privacy. The entity assesses those parties’ compliance on a periodic and as-needed basis and takes corrective action, if necessary
|
||||||
|
P6.5:
|
||||||
|
family: P6
|
||||||
|
name: Unauthorized Third Party Disclosure
|
||||||
|
description: The entity obtains commitments from vendors and other third parties with access to personal information to notify the entity in the event of actual or suspected unauthorized disclosures of personal information. Such notifications are reported to appropriate personnel and acted on in accordance with established incident response procedures to meet the entity’s objectives related to privacy
|
||||||
|
P6.6:
|
||||||
|
family: P6
|
||||||
|
name: Notification of Unauthorized Third Party Disclosure
|
||||||
|
description: The entity provides notification of breaches and incidents to affected data subjects, regulators, and others to meet the entity’s objectives related to privacy
|
||||||
|
P6.7:
|
||||||
|
family: P6
|
||||||
|
name: Accounting of Personal Information
|
||||||
|
description: The entity provides data subjects with an accounting of the personal information held and disclosure of the data subjects’ personal information, upon the data subjects’ request, to meet the entity’s objectives related to privacy
|
||||||
|
P7.1:
|
||||||
|
family: P7
|
||||||
|
name: Accuracy of Personal Information
|
||||||
|
description: The entity collects and maintains accurate, up-to-date, complete, and relevant personal information to meet the entity’s objectives related to privacy
|
||||||
|
P8.1:
|
||||||
|
family: P8
|
||||||
|
name: Personal Information Dispute Resolution
|
||||||
|
description: The entity implements a process for receiving, addressing, resolving, and communicating the resolution of inquiries, complaints, and disputes from data subjects and others and periodically monitors compliance to meet the entity’s objectives related to privacy. Corrections and other necessary actions related to identified deficiencies are made or taken in a timely manner
|
@ -83,7 +83,10 @@ func ReadStandards() ([]*Standard, error) {
|
|||||||
return nil, errors.Wrap(err, "unable to read "+f.FullPath)
|
return nil, errors.Wrap(err, "unable to read "+f.FullPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
yaml.Unmarshal(sBytes, &s)
|
err = yaml.Unmarshal(sBytes, &s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "unable to parse "+f.FullPath)
|
||||||
|
}
|
||||||
standards = append(standards, s)
|
standards = append(standards, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,6 +126,7 @@ func ReadNarratives() ([]*Document, error) {
|
|||||||
func ReadProcedures() ([]*Procedure, error) {
|
func ReadProcedures() ([]*Procedure, error) {
|
||||||
var procedures []*Procedure
|
var procedures []*Procedure
|
||||||
files, err := path.Procedures()
|
files, err := path.Procedures()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "unable to enumerate paths")
|
return nil, errors.Wrap(err, "unable to enumerate paths")
|
||||||
}
|
}
|
||||||
@ -194,7 +198,7 @@ func loadMDMD(path string) (*metadataMarkdown, error) {
|
|||||||
if len(components) == 1 {
|
if len(components) == 1 {
|
||||||
return nil, errors.New(fmt.Sprintf("Malformed metadata markdown in %s, must be of the form: YAML\\n---\\nmarkdown content", path))
|
return nil, errors.New(fmt.Sprintf("Malformed metadata markdown in %s, must be of the form: YAML\\n---\\nmarkdown content", path))
|
||||||
}
|
}
|
||||||
yaml := components[0]
|
item := components[0]
|
||||||
body := strings.Join(components[1:], "---")
|
body := strings.Join(components[1:], "---")
|
||||||
return &metadataMarkdown{yaml, body}, nil
|
return &metadataMarkdown{item, body}, nil
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ func TestReadNarratives(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestReadNarratives calls model.ReadNarratives checking for a valid return when
|
// TestReadNarrativesWhenThereAreNoNarratives calls model.ReadNarratives checking for a valid return when
|
||||||
// there are no narratives to process
|
// there are no narratives to process
|
||||||
func TestReadNarrativesWhenThereAreNoNarratives(t *testing.T) {
|
func TestReadNarrativesWhenThereAreNoNarratives(t *testing.T) {
|
||||||
mockConfig()
|
mockConfig()
|
||||||
@ -53,7 +53,7 @@ func TestReadNarrativesWhenThereAreNoNarratives(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestReadNarratives calls model.ReadNarratives checking for an error return when
|
// TestReadNarrativesFailsWhenInvalidNarrative calls model.ReadNarratives checking for an error return when
|
||||||
// there is an invalid narrative
|
// there is an invalid narrative
|
||||||
func TestReadNarrativesFailsWhenInvalidNarrative(t *testing.T) {
|
func TestReadNarrativesFailsWhenInvalidNarrative(t *testing.T) {
|
||||||
mockConfig()
|
mockConfig()
|
||||||
@ -71,11 +71,185 @@ func TestReadNarrativesFailsWhenInvalidNarrative(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestReadProcedures calls model.ReadProcedures checking for a valid return value.
|
||||||
|
func TestReadProcedures(t *testing.T) {
|
||||||
|
mockConfig()
|
||||||
|
filePath := fmt.Sprintf("%s/procedures/workstation.md", getRootPath())
|
||||||
|
fileInfo, _ := os.Lstat(filePath)
|
||||||
|
path.Procedures = func() ([]path.File, error) {
|
||||||
|
return []path.File{
|
||||||
|
{FullPath: filePath, Info: fileInfo},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
documents, err := ReadProcedures()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(`ReadProcedures() returned an error %v`, err)
|
||||||
|
}
|
||||||
|
if len(documents) != 1 {
|
||||||
|
t.Fatal(`Invalid number of documents`)
|
||||||
|
}
|
||||||
|
if documents[0].FullPath != filePath {
|
||||||
|
t.Fatalf(`Invalid document path %s`, documents[0].FullPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestReadProceduresWhenThereAreNoProcedures calls model.ReadProcedures checking for a valid return when
|
||||||
|
// there are no procedures to process
|
||||||
|
func TestReadProceduresWhenThereAreNoProcedures(t *testing.T) {
|
||||||
|
mockConfig()
|
||||||
|
path.Procedures = func() ([]path.File, error) {
|
||||||
|
return []path.File{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
documents, err := ReadProcedures()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(`ReadProcedures() returned an error %v`, err)
|
||||||
|
}
|
||||||
|
if len(documents) != 0 {
|
||||||
|
t.Fatal(`Invalid number of documents`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestReadProceduresFailsWhenInvalidProcedure calls model.ReadProcedures checking for an error return when
|
||||||
|
// there is an invalid procedure
|
||||||
|
func TestReadProceduresFailsWhenInvalidProcedure(t *testing.T) {
|
||||||
|
mockConfig()
|
||||||
|
path.Procedures = func() ([]path.File, error) {
|
||||||
|
filePath := fmt.Sprintf("%s/../fixtures/procedures/invalid-workstation.md", getRootPath())
|
||||||
|
fileInfo, _ := os.Lstat(filePath)
|
||||||
|
return []path.File{
|
||||||
|
{FullPath: filePath, Info: fileInfo},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := ReadProcedures()
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal(`ReadProcedures() was expected to fail`, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestReadPolicies calls model.ReadPolicies checking for a valid return value.
|
||||||
|
func TestReadPolicies(t *testing.T) {
|
||||||
|
mockConfig()
|
||||||
|
filePath := fmt.Sprintf("%s/policies/access.md", getRootPath())
|
||||||
|
fileInfo, _ := os.Lstat(filePath)
|
||||||
|
path.Policies = func() ([]path.File, error) {
|
||||||
|
return []path.File{
|
||||||
|
{FullPath: filePath, Info: fileInfo},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
documents, err := ReadPolicies()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(`ReadPolicies() returned an error %v`, err)
|
||||||
|
}
|
||||||
|
if len(documents) != 1 {
|
||||||
|
t.Fatal(`Invalid number of documents`)
|
||||||
|
}
|
||||||
|
if documents[0].FullPath != filePath {
|
||||||
|
t.Fatalf(`Invalid document path %s`, documents[0].FullPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestReadPoliciesWhenThereAreNoPolicies calls model.ReadPolicies checking for a valid return when
|
||||||
|
// there are no policies to process
|
||||||
|
func TestReadPoliciesWhenThereAreNoPolicies(t *testing.T) {
|
||||||
|
mockConfig()
|
||||||
|
path.Policies = func() ([]path.File, error) {
|
||||||
|
return []path.File{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
documents, err := ReadPolicies()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(`ReadPolicies() returned an error %v`, err)
|
||||||
|
}
|
||||||
|
if len(documents) != 0 {
|
||||||
|
t.Fatal(`Invalid number of documents`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestReadPoliciesFailsWhenInvalidPolicy calls model.ReadPolicies checking for an error return when
|
||||||
|
// there is an invalid policy
|
||||||
|
func TestReadPoliciesFailsWhenInvalidPolicy(t *testing.T) {
|
||||||
|
mockConfig()
|
||||||
|
path.Policies = func() ([]path.File, error) {
|
||||||
|
filePath := fmt.Sprintf("%s/../fixtures/policies/invalid-access.md", getRootPath())
|
||||||
|
fileInfo, _ := os.Lstat(filePath)
|
||||||
|
return []path.File{
|
||||||
|
{FullPath: filePath, Info: fileInfo},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := ReadPolicies()
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal(`ReadPolicies() was expected to fail`, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestReadStandards calls model.ReadStandards checking for a valid return value.
|
||||||
|
func TestReadStandards(t *testing.T) {
|
||||||
|
mockConfig()
|
||||||
|
filePath := fmt.Sprintf("%s/standards/TSC-2017.yml", getRootPath())
|
||||||
|
fileInfo, _ := os.Lstat(filePath)
|
||||||
|
path.Standards = func() ([]path.File, error) {
|
||||||
|
return []path.File{
|
||||||
|
{FullPath: filePath, Info: fileInfo},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
documents, err := ReadStandards()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(`ReadStandards() returned an error %v`, err)
|
||||||
|
}
|
||||||
|
if len(documents) != 1 {
|
||||||
|
t.Fatal(`Invalid number of documents`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestReadStandardsWhenThereAreNoStandards calls model.ReadStandards checking for a valid return when
|
||||||
|
// there are no standards to process
|
||||||
|
func TestReadStandardsWhenThereAreNoStandards(t *testing.T) {
|
||||||
|
mockConfig()
|
||||||
|
path.Standards = func() ([]path.File, error) {
|
||||||
|
return []path.File{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
documents, err := ReadStandards()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(`ReadStandards() returned an error %v`, err)
|
||||||
|
}
|
||||||
|
if len(documents) != 0 {
|
||||||
|
t.Fatal(`Invalid number of documents`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestReadStandardsFailsWhenInvalidStandard calls model.ReadStandards checking for an error return when
|
||||||
|
// there is an invalid standard
|
||||||
|
func TestReadStandardsFailsWhenInvalidStandard(t *testing.T) {
|
||||||
|
mockConfig()
|
||||||
|
path.Standards = func() ([]path.File, error) {
|
||||||
|
filePath := fmt.Sprintf("%s/../fixtures/standards/invalid-standard.yml", getRootPath())
|
||||||
|
fileInfo, _ := os.Lstat(filePath)
|
||||||
|
return []path.File{
|
||||||
|
{FullPath: filePath, Info: fileInfo},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := ReadStandards()
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal(`ReadStandards() was expected to fail`, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func mockConfig() {
|
func mockConfig() {
|
||||||
config.Config = func() *config.Project {
|
config.Config = func() *config.Project {
|
||||||
p := config.Project{}
|
p := config.Project{}
|
||||||
cfgBytes, _ := ioutil.ReadFile(filepath.Join(getRootPath(), "comply.yml.example"))
|
cfgBytes, _ := ioutil.ReadFile(filepath.Join(getRootPath(), "comply.yml.example"))
|
||||||
yaml.Unmarshal(cfgBytes, &p)
|
err := yaml.Unmarshal(cfgBytes, &p)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return &p
|
return &p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user