Class: Test

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
models/test.rb

Overview

A single security test of an Application

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from DataMapper::Resource

#make_dirty

Class Method Details

+ (Array<Test>) allWithFlags(selectedFlags, params = {})

Get Tests that are on apps with any of the given flags and match given parameters. This method passes through to Test.all with additional parameters to properly filter by flag

Parameters:

  • selectedFlags (Array)

    Array of flag IDs to filter by

  • params (Hash) (defaults to: {})

    Additional params to pass to Test.all

Returns:

  • (Array<Test>)

    Matching Tests



114
115
116
117
118
119
120
# File 'models/test.rb', line 114

def self.allWithFlags(selectedFlags, params={})
	if(selectedFlags.include?(-1))
		return all(params)
	else
		return all({Test.application.flags.id => selectedFlags}.merge(params))
	end
end

+ (Application) application(repository = nil)

Returns Application this Test belongs to

Returns:



43
# File 'models/test.rb', line 43

belongs_to :application, :required => false

+ (Integer) application_id(repository = nil)

Returns ID of Application the Test belongs to

Returns:



14
# File 'models/test.rb', line 14

property :application_id,  		Integer

+ (Integer) approved_by(repository = nil)

Returns UID of User who approved or rejected approval flow results

Returns:

  • (Integer)

    UID of User who approved or rejected approval flow results



32
# File 'models/test.rb', line 32

property :approved_by,			Integer, :default => 0

+ (DateTime) closed_at(repository = nil)

Returns Date/Time this Test was closed (completed)

Returns:

  • (DateTime)

    Date/Time this Test was closed (completed)



25
# File 'models/test.rb', line 25

property :closed_at, 			DateTime

+ (Boolean) complete(repository = nil)

Returns True if Test is complete. Only true when entire test is complete / all approvals done

Returns:

  • (Boolean)

    True if Test is complete. Only true when entire test is complete / all approvals done



34
# File 'models/test.rb', line 34

property :complete,				Boolean, :default => false

+ (DateTime) con_closed_at(repository = nil)

Returns Date/Time this Test was closed by contractor (nil if not contractor test)

Returns:

  • (DateTime)

    Date/Time this Test was closed by contractor (nil if not contractor test)



24
# File 'models/test.rb', line 24

property :con_closed_at,		DateTime

+ (Boolean) contractor_test(repository = nil)

Returns True if this test is being done by a contractor

Returns:

  • (Boolean)

    True if this test is being done by a contractor



27
# File 'models/test.rb', line 27

property :contractor_test,		Boolean, :default => false

+ (Array<Test>) countWithFlags(selectedFlags, params = {})

Count Tests that have the given flags and match given parameters. This method passes through to Test.count with additional parameters to properly filter by flag

Parameters:

  • selectedFlags (Array<Integer>)

    Flags to filter by

  • params (Hash) (defaults to: {})

    Additional params to pass to Test.count

Returns:

  • (Array<Test>)

    Number of matching Tests



128
129
130
# File 'models/test.rb', line 128

def self.countWithFlags(selectedFlags, params={})
	return allWithFlags(selectedFlags, params.merge({:fields => [:id]})).size
end

+ (DateTime) created_at(repository = nil)

Returns Date/Time this Test was created (DM handled)

Returns:

  • (DateTime)

    Date/Time this Test was created (DM handled)



21
# File 'models/test.rb', line 21

property :created_at, 			DateTime

+ (Array<Test>) createdBy(oid)

Get all Tests created by given OrgId

Parameters:

  • oid (Integer)

    ID of Organization to get Tests created by

Returns:

  • (Array<Test>)

    All Tests created by given Organization



104
105
106
# File 'models/test.rb', line 104

def self.createdBy(oid)
	all(:org_created => oid, :order => [ :id.desc ])
end

+ (String) description(repository = nil)

Returns Test description

Returns:

  • (String)

    Test description



16
# File 'models/test.rb', line 16

property :description, 			Text

+ (String) disagree_reason(repository = nil)

Returns Reason #approved_by User disagreed with approval flow results

Returns:



33
# File 'models/test.rb', line 33

property :disagree_reason,		Text

+ (String) ext_eid(repository = nil)

Returns External entity ID for this test (reference only)

Returns:

  • (String)

    External entity ID for this test (reference only)



19
# File 'models/test.rb', line 19

property :ext_eid,				String

+ (Integer) id(repository = nil)

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



13
# File 'models/test.rb', line 13

property :id, 					Serial

+ (Boolean) is_pending(repository = nil)

Returns True if this test is currently pending approver review

Returns:

  • (Boolean)

    True if this test is currently pending approver review



28
# File 'models/test.rb', line 28

property :is_pending,			Boolean, :default => false

+ (String) name(repository = nil)

Returns Test name

Returns:

  • (String)

    Test name



15
# File 'models/test.rb', line 15

property :name, 				String, :length => 100

+ (Integer) org_created(repository = nil)

Returns ID of Organization that created Test

Returns:



17
# File 'models/test.rb', line 17

property :org_created,			Integer, :default => 1

+ (Boolean) pass(repository = nil)

Returns True if Test is passed (True if prov pass)

Returns:

  • (Boolean)

    True if Test is passed (True if prov pass)



35
# File 'models/test.rb', line 35

property :pass,					Boolean, :default => false

+ (DateTime) pending_at(repository = nil)

Returns Date/Time this Test was put into pending approval state

Returns:

  • (DateTime)

    Date/Time this Test was put into pending approval state



23
# File 'models/test.rb', line 23

property :pending_at,			DateTime

+ (Integer) pending_by(repository = nil)

Returns ID of the User who put this test in pending state

Returns:

  • (Integer)

    ID of the User who put this test in pending state



29
# File 'models/test.rb', line 29

property :pending_by,			Integer

+ (Boolean) pending_pass(repository = nil)

Returns True if this test is pending review to be passed, false if failed

Returns:

  • (Boolean)

    True if this test is pending review to be passed, false if failed



30
# File 'models/test.rb', line 30

property :pending_pass,			Boolean, :default => false

+ (Boolean) provPass(repository = nil)

Returns True if provisional pass has been approved

Returns:

  • (Boolean)

    True if provisional pass has been approved



37
# File 'models/test.rb', line 37

property :provPass,				Boolean, :default => false

+ (Integer) provPassApprover(repository = nil)

Returns UID of User who approved the provisional pass

Returns:

  • (Integer)

    UID of User who approved the provisional pass



39
# File 'models/test.rb', line 39

property :provPassApprover,		Integer, :default => 0

+ (Date) provPassExpiry(repository = nil)

Returns Date the Prov Pass for this test will expire

Returns:

  • (Date)

    Date the Prov Pass for this test will expire



40
# File 'models/test.rb', line 40

property :provPassExpiry,		Date

+ (Boolean) provPassReq(repository = nil)

Returns True if provisional pass has been requested

Returns:

  • (Boolean)

    True if provisional pass has been requested



36
# File 'models/test.rb', line 36

property :provPassReq,			Boolean, :default => false

+ (Integer) provPassRequestor(repository = nil)

Returns UID of User who requested provisional pass

Returns:

  • (Integer)

    UID of User who requested provisional pass



38
# File 'models/test.rb', line 38

property :provPassRequestor,	Integer, :default => 0

+ (Integer) reviewer(repository = nil)

Returns ID of User who is reviewer for Test

Returns:

  • (Integer)

    ID of User who is reviewer for Test



18
# File 'models/test.rb', line 18

property :reviewer, 			Integer

+ (DateTime) updated_at(repository = nil)

Returns Date/Time this Test was last updated (DM handled)

Returns:

  • (DateTime)

    Date/Time this Test was last updated (DM handled)



22
# File 'models/test.rb', line 22

property :updated_at, 			DateTime

Instance Method Details

- (Application) application

Returns Application this Test belongs to

Returns:



43
# File 'models/test.rb', line 43

belongs_to :application, :required => false

- (Application) application=(resource)

Returns Application this Test belongs to

Returns:



43
# File 'models/test.rb', line 43

belongs_to :application, :required => false

- (Integer) application_id

Returns ID of Application the Test belongs to

Returns:



14
# File 'models/test.rb', line 14

property :application_id,  		Integer

- (Integer) application_id=(value)

Returns ID of Application the Test belongs to

Returns:



14
# File 'models/test.rb', line 14

property :application_id,  		Integer

- (Integer) approved_by

Returns UID of User who approved or rejected approval flow results

Returns:

  • (Integer)

    UID of User who approved or rejected approval flow results



32
# File 'models/test.rb', line 32

property :approved_by,			Integer, :default => 0

- (Integer) approved_by=(value)

Returns UID of User who approved or rejected approval flow results

Returns:

  • (Integer)

    UID of User who approved or rejected approval flow results



32
# File 'models/test.rb', line 32

property :approved_by,			Integer, :default => 0

- (DateTime) closed_at

Returns Date/Time this Test was closed (completed)

Returns:

  • (DateTime)

    Date/Time this Test was closed (completed)



25
# File 'models/test.rb', line 25

property :closed_at, 			DateTime

- (DateTime) closed_at=(value)

Returns Date/Time this Test was closed (completed)

Returns:

  • (DateTime)

    Date/Time this Test was closed (completed)



25
# File 'models/test.rb', line 25

property :closed_at, 			DateTime

- (Boolean) complete

Returns True if Test is complete. Only true when entire test is complete / all approvals done

Returns:

  • (Boolean)

    True if Test is complete. Only true when entire test is complete / all approvals done



34
# File 'models/test.rb', line 34

property :complete,				Boolean, :default => false

- (Boolean) complete=(value)

Returns True if Test is complete. Only true when entire test is complete / all approvals done

Returns:

  • (Boolean)

    True if Test is complete. Only true when entire test is complete / all approvals done



34
# File 'models/test.rb', line 34

property :complete,				Boolean, :default => false

- (DateTime) con_closed_at

Returns Date/Time this Test was closed by contractor (nil if not contractor test)

Returns:

  • (DateTime)

    Date/Time this Test was closed by contractor (nil if not contractor test)



24
# File 'models/test.rb', line 24

property :con_closed_at,		DateTime

- (DateTime) con_closed_at=(value)

Returns Date/Time this Test was closed by contractor (nil if not contractor test)

Returns:

  • (DateTime)

    Date/Time this Test was closed by contractor (nil if not contractor test)



24
# File 'models/test.rb', line 24

property :con_closed_at,		DateTime

- (Boolean) contractor_test

Returns True if this test is being done by a contractor

Returns:

  • (Boolean)

    True if this test is being done by a contractor



27
# File 'models/test.rb', line 27

property :contractor_test,		Boolean, :default => false

- (Boolean) contractor_test=(value)

Returns True if this test is being done by a contractor

Returns:

  • (Boolean)

    True if this test is being done by a contractor



27
# File 'models/test.rb', line 27

property :contractor_test,		Boolean, :default => false

- (DateTime) created_at

Returns Date/Time this Test was created (DM handled)

Returns:

  • (DateTime)

    Date/Time this Test was created (DM handled)



21
# File 'models/test.rb', line 21

property :created_at, 			DateTime

- (DateTime) created_at=(value)

Returns Date/Time this Test was created (DM handled)

Returns:

  • (DateTime)

    Date/Time this Test was created (DM handled)



21
# File 'models/test.rb', line 21

property :created_at, 			DateTime

- (String) description

Returns Test description

Returns:

  • (String)

    Test description



16
# File 'models/test.rb', line 16

property :description, 			Text

- (String) description=(value)

Returns Test description

Returns:

  • (String)

    Test description



16
# File 'models/test.rb', line 16

property :description, 			Text

- (String) disagree_reason

Returns Reason #approved_by User disagreed with approval flow results

Returns:



33
# File 'models/test.rb', line 33

property :disagree_reason,		Text

- (String) disagree_reason=(value)

Returns Reason #approved_by User disagreed with approval flow results

Returns:



33
# File 'models/test.rb', line 33

property :disagree_reason,		Text

- (String) ext_eid

Returns External entity ID for this test (reference only)

Returns:

  • (String)

    External entity ID for this test (reference only)



19
# File 'models/test.rb', line 19

property :ext_eid,				String

- (String) ext_eid=(value)

Returns External entity ID for this test (reference only)

Returns:

  • (String)

    External entity ID for this test (reference only)



19
# File 'models/test.rb', line 19

property :ext_eid,				String

- (Integer) id

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



13
# File 'models/test.rb', line 13

property :id, 					Serial

- (Integer) id=(value)

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



13
# File 'models/test.rb', line 13

property :id, 					Serial

- (Boolean) is_pending

Returns True if this test is currently pending approver review

Returns:

  • (Boolean)

    True if this test is currently pending approver review



28
# File 'models/test.rb', line 28

property :is_pending,			Boolean, :default => false

- (Boolean) is_pending=(value)

Returns True if this test is currently pending approver review

Returns:

  • (Boolean)

    True if this test is currently pending approver review



28
# File 'models/test.rb', line 28

property :is_pending,			Boolean, :default => false

- (Boolean) isAppLinked?

Returns Application.isLinked? for parent Application

Returns:

  • (Boolean)

    True if parent Application is linked



82
83
84
# File 'models/test.rb', line 82

def isAppLinked?
	return self.application.isLinked?
end

- (String) name

Returns Test name

Returns:

  • (String)

    Test name



15
# File 'models/test.rb', line 15

property :name, 				String, :length => 100

- (String) name=(value)

Returns Test name

Returns:

  • (String)

    Test name



15
# File 'models/test.rb', line 15

property :name, 				String, :length => 100

- (Integer) org_created

Returns ID of Organization that created Test

Returns:



17
# File 'models/test.rb', line 17

property :org_created,			Integer, :default => 1

- (Integer) org_created=(value)

Returns ID of Organization that created Test

Returns:



17
# File 'models/test.rb', line 17

property :org_created,			Integer, :default => 1

- (Boolean) pass

Returns True if Test is passed (True if prov pass)

Returns:

  • (Boolean)

    True if Test is passed (True if prov pass)



35
# File 'models/test.rb', line 35

property :pass,					Boolean, :default => false

- (Boolean) pass=(value)

Returns True if Test is passed (True if prov pass)

Returns:

  • (Boolean)

    True if Test is passed (True if prov pass)



35
# File 'models/test.rb', line 35

property :pass,					Boolean, :default => false

- (DateTime) pending_at

Returns Date/Time this Test was put into pending approval state

Returns:

  • (DateTime)

    Date/Time this Test was put into pending approval state



23
# File 'models/test.rb', line 23

property :pending_at,			DateTime

- (DateTime) pending_at=(value)

Returns Date/Time this Test was put into pending approval state

Returns:

  • (DateTime)

    Date/Time this Test was put into pending approval state



23
# File 'models/test.rb', line 23

property :pending_at,			DateTime

- (Integer) pending_by

Returns ID of the User who put this test in pending state

Returns:

  • (Integer)

    ID of the User who put this test in pending state



29
# File 'models/test.rb', line 29

property :pending_by,			Integer

- (Integer) pending_by=(value)

Returns ID of the User who put this test in pending state

Returns:

  • (Integer)

    ID of the User who put this test in pending state



29
# File 'models/test.rb', line 29

property :pending_by,			Integer

- (Boolean) pending_pass

Returns True if this test is pending review to be passed, false if failed

Returns:

  • (Boolean)

    True if this test is pending review to be passed, false if failed



30
# File 'models/test.rb', line 30

property :pending_pass,			Boolean, :default => false

- (Boolean) pending_pass=(value)

Returns True if this test is pending review to be passed, false if failed

Returns:

  • (Boolean)

    True if this test is pending review to be passed, false if failed



30
# File 'models/test.rb', line 30

property :pending_pass,			Boolean, :default => false

- (Boolean) provPass

Returns True if provisional pass has been approved

Returns:

  • (Boolean)

    True if provisional pass has been approved



37
# File 'models/test.rb', line 37

property :provPass,				Boolean, :default => false

- (Boolean) provPass=(value)

Returns True if provisional pass has been approved

Returns:

  • (Boolean)

    True if provisional pass has been approved



37
# File 'models/test.rb', line 37

property :provPass,				Boolean, :default => false

- (Integer) provPassApprover

Returns UID of User who approved the provisional pass

Returns:

  • (Integer)

    UID of User who approved the provisional pass



39
# File 'models/test.rb', line 39

property :provPassApprover,		Integer, :default => 0

- (Integer) provPassApprover=(value)

Returns UID of User who approved the provisional pass

Returns:

  • (Integer)

    UID of User who approved the provisional pass



39
# File 'models/test.rb', line 39

property :provPassApprover,		Integer, :default => 0

- (Date) provPassExpiry

Returns Date the Prov Pass for this test will expire

Returns:

  • (Date)

    Date the Prov Pass for this test will expire



40
# File 'models/test.rb', line 40

property :provPassExpiry,		Date

- (Date) provPassExpiry=(value)

Returns Date the Prov Pass for this test will expire

Returns:

  • (Date)

    Date the Prov Pass for this test will expire



40
# File 'models/test.rb', line 40

property :provPassExpiry,		Date

- (Boolean) provPassReq

Returns True if provisional pass has been requested

Returns:

  • (Boolean)

    True if provisional pass has been requested



36
# File 'models/test.rb', line 36

property :provPassReq,			Boolean, :default => false

- (Boolean) provPassReq=(value)

Returns True if provisional pass has been requested

Returns:

  • (Boolean)

    True if provisional pass has been requested



36
# File 'models/test.rb', line 36

property :provPassReq,			Boolean, :default => false

- (Integer) provPassRequestor

Returns UID of User who requested provisional pass

Returns:

  • (Integer)

    UID of User who requested provisional pass



38
# File 'models/test.rb', line 38

property :provPassRequestor,	Integer, :default => 0

- (Integer) provPassRequestor=(value)

Returns UID of User who requested provisional pass

Returns:

  • (Integer)

    UID of User who requested provisional pass



38
# File 'models/test.rb', line 38

property :provPassRequestor,	Integer, :default => 0

- (Integer) record_type

Get the parent Application's RecordType ID

Returns:

  • (Integer)

    ID of parent Application's RecordType



89
90
91
# File 'models/test.rb', line 89

def record_type
	return self.application.record_type
end

- (Integer) reviewer

Returns ID of User who is reviewer for Test

Returns:

  • (Integer)

    ID of User who is reviewer for Test



18
# File 'models/test.rb', line 18

property :reviewer, 			Integer

- (Integer) reviewer=(value)

Returns ID of User who is reviewer for Test

Returns:

  • (Integer)

    ID of User who is reviewer for Test



18
# File 'models/test.rb', line 18

property :reviewer, 			Integer

- (String) reviewerName

Get name of Test's reviewer

Returns:

  • (String)

    Name of reviewer of this test



96
97
98
# File 'models/test.rb', line 96

def reviewerName
	return User.get(self.reviewer).name
end

- (String) status_icon

Get HTML string of icon representing Test's status

Returns:

  • (String)

    HTML of icon for Test's status



49
50
51
52
53
54
55
56
57
58
# File 'models/test.rb', line 49

def status_icon
	return '<i class="fa fa-clock-o" rel="tooltip" title="Test Awaiting Review"></i> <i class="fa fa-check" rel="tooltip" title="Pending Pass" style="color:#009933; opacity:0.4"></i>' if (!complete && is_pending && pending_pass && !provPassReq)
	return '<i class="fa fa-clock-o" rel="tooltip" title="Test Awaiting Review"></i> <i class="fa fa-frown-o" rel="tooltip" title="Pending Fail" style="color:#B40404; opacity:0.4""></i>' if (!complete && is_pending && !pending_pass && !provPassReq)
	return '<i class="fa fa-clock-o" rel="tooltip" title="Test Awaiting Review"></i>' if (!complete && is_pending && !provPassReq)
	return '<i class="fa fa-warning" rel="tooltip" title="Provisional Pass Requested" style="color:#EEA236; opacity:0.4;"></i>' if (!complete && pass && provPassReq && !provPass)
	return '<i class="fa fa-check" rel="tooltip" title="Provisional Pass" style="color:#EEA236;"></i>' if (complete && pass && provPassReq && provPass)
	return '<i class="fa fa-clock-o" rel="tooltip" title="Test In Progress"></i>' if (!complete)
	return '<i class="fa fa-check" rel="tooltip" title="Test Passed" style="color:#009933;"></i>' if (complete && pass)
	return '<i class="fa fa-frown-o" rel="tooltip" title="Test Failed" style="color:#B40404;"></i>' if (complete && !pass)
end

- (String) status_text

Get HTML string of text representing Test's status

Returns:

  • (String)

    HTML text for Test's status



63
64
65
66
67
68
69
70
# File 'models/test.rb', line 63

def status_text
	return "Awaiting Review" if (!complete && is_pending && !provPassReq)
	return '<span style="color:#EEA236;">Provisional Requested</span>' if (!complete && pass && provPassReq && !provPass)
	return '<span style="color:#EEA236;">Provisionally Passed</span>' if (complete && pass && provPassReq && provPass)
	return "In Progress" if (!complete)
	return '<span style="color:#009933;">Test Passed</span>' if (complete && pass)
	return '<span style="color:#B40404;">Test Failed</span>' if (complete && !pass)
end

- (DateTime) updated_at

Returns Date/Time this Test was last updated (DM handled)

Returns:

  • (DateTime)

    Date/Time this Test was last updated (DM handled)



22
# File 'models/test.rb', line 22

property :updated_at, 			DateTime

- (DateTime) updated_at=(value)

Returns Date/Time this Test was last updated (DM handled)

Returns:

  • (DateTime)

    Date/Time this Test was last updated (DM handled)



22
# File 'models/test.rb', line 22

property :updated_at, 			DateTime

- (Array<Vulnerability>) verified_vulns

Get all verified Vulnerability objects attached to this Test

Returns:



75
76
77
# File 'models/test.rb', line 75

def verified_vulns
	return vulnerabilities(:verified => true, :falsepos => false).sort{ |x,y| x.vuln_priority <=> y.vuln_priority }
end