Class: Soar::Policy::AccessManager::Test::OrchestrationProvider::ServiceRegistry::Services

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

Instance Method Summary collapse

Constructor Details

#initializeServices

Returns a new instance of Services.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/soar/policy/access_manager/test/orchestration_provider/service_registry.rb', line 17

def initialize()
  @policy_host = ENV['POLICY_HOST'] || 'localhost:8080'
  @meta = {
    'service_identifier1' => {
      'policy' => 'allow'
    },
    'service_identifier2' => {
      'policy' => 'deny'
    }
  }
end

Instance Method Details

#meta_for_service(service_identifier) ⇒ Object



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

def meta_for_service(service_identifier)
  @meta[service_identifier]
end

#service_by_name(policy) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/soar/policy/access_manager/test/orchestration_provider/service_registry.rb', line 29

def service_by_name(policy)
  case policy
    when 'allow' # allow policy
      success_data({
        "services" => [[{}, { "uris" => [[{}, { "access_point" => "http://#{@policy_host}/allow" }]]}]]
      })
    when 'deny' # deny policy
      success_data({
        "services" => [[{}, { "uris" => [[{}, { "access_point" => "http://#{@policy_host}/deny" }]]}]]
      })
    else # no policy
      success_data({
        "services" => [[{}, { "uris" => [[{}, { "access_point" => "http://#{@policy_host}/" }]]}]]
      })
  end
end