Class: Soar::Policy::AccessManager::Test::OrchestrationProvider::Stub

Inherits:
Object
  • Object
show all
Defined in:
lib/soar/policy/access_manager/test/orchestration_provider/stub.rb

Instance Method Summary collapse

Constructor Details

#initializeStub

Returns a new instance of Stub.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/soar/policy/access_manager/test/orchestration_provider/stub.rb', line 12

def initialize
  @meta = {
    'service_identifier1' => {
      'policy' => 'policy1'
    }
  }
  @policies = {
    'policy1' => {
      'resource_identifier1' => ['authentication_identifier1'],
      'resource_identifier2' => []
    }
  }
  @request = {
    params: {},
    authentication_identifier: 'authentication_identifier1'
  }
end

Instance Method Details

#authorizedObject



55
56
57
# File 'lib/soar/policy/access_manager/test/orchestration_provider/stub.rb', line 55

def authorized
  @response['data']['approved']
end

#authorized?Boolean

Returns:

  • (Boolean)


49
50
51
52
53
# File 'lib/soar/policy/access_manager/test/orchestration_provider/stub.rb', line 49

def authorized?
  model_provider = Soar::Policy::AccessManager::ModelProvider::Stub.new(meta: @meta, policies: @policies)
  model = Soar::Policy::AccessManager::Model.new(model_provider)
  @response = model.authorized?(service_identifier: @service_identifier, resource_identifier: @resource_identifier, request: @request)
end

#deny_accessObject



35
36
37
38
# File 'lib/soar/policy/access_manager/test/orchestration_provider/stub.rb', line 35

def deny_access
  @service_identifier = 'service_identifier1'
  @resource_identifier = 'resource_identifier2'
end

#grant_accessObject



30
31
32
33
# File 'lib/soar/policy/access_manager/test/orchestration_provider/stub.rb', line 30

def grant_access
  @service_identifier = 'service_identifier1'
  @resource_identifier = 'resource_identifier1'
end

#no_policyObject



40
41
42
43
# File 'lib/soar/policy/access_manager/test/orchestration_provider/stub.rb', line 40

def no_policy
  @service_identifier = 'service_identifier2'
  @resource_identifier = nil
end

#notificationObject



45
46
47
# File 'lib/soar/policy/access_manager/test/orchestration_provider/stub.rb', line 45

def notification
  @response['data']['notifications']
end