• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NIT-Administrative-Systems / SysDev-laravel-soa / 7805057844

06 Feb 2024 07:28PM UTC coverage: 45.675% (-0.2%) from 45.913%
7805057844

push

github

web-flow
Housekeeping (#162)

11 of 35 new or added lines in 14 files covered. (31.43%)

9 existing lines in 7 files now uncovered.

264 of 578 relevant lines covered (45.67%)

14.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.92
/src/Providers/NuSoaServiceProvider.php
1
<?php
2

3
namespace Northwestern\SysDev\SOA\Providers;
4

5
use Illuminate\Routing\Route;
6
use Illuminate\Support\Facades\Event;
7
use Illuminate\Support\ServiceProvider;
8
use Northwestern\SysDev\SOA\Auth\OAuth2\NorthwesternAzureExtendSocialite;
9
use Northwestern\SysDev\SOA\Auth\Strategy\OpenAM11;
10
use Northwestern\SysDev\SOA\Auth\Strategy\WebSSOStrategy;
11
use Northwestern\SysDev\SOA\Console\Commands;
12
use Northwestern\SysDev\SOA\DirectorySearch;
13
use Northwestern\SysDev\SOA\EventHub;
14
use Northwestern\SysDev\SOA\Http\Middleware\VerifyEventHubHMAC;
15
use Northwestern\SysDev\SOA\Routing\EventHubWebhookRegistration;
16
use Northwestern\SysDev\SOA\WebSSO;
17
use Northwestern\SysDev\SOA\WebSSOImpl\ApigeeAgentless;
18
use Northwestern\SysDev\SOA\WebSSOImpl\OpenAM11Api;
19
use SocialiteProviders\Manager\SocialiteWasCalled;
20

21
class NuSoaServiceProvider extends ServiceProvider
22
{
23
    public function register()
24
    {
25
        $this->mergeConfigFrom(__DIR__.'/../../config/nusoa.php', 'nusoa');
96✔
26
    } // end register
27

28
    public function boot()
29
    {
30
        $this->publishes([
96✔
31
            __DIR__.'/../../config/nusoa.php' => config_path('nusoa.php'),
96✔
32
        ], 'config');
96✔
33

34
        if ($this->app->runningInConsole()) {
96✔
35
            $this->commands([
96✔
36
                Commands\EventHub\QueueOverview::class,
96✔
37
                Commands\EventHub\TopicOverview::class,
96✔
38
                Commands\EventHub\WebhookStatus::class,
96✔
39
                Commands\EventHub\WebhookToggle::class,
96✔
40
                Commands\EventHub\WebhookConfiguration::class,
96✔
41

42
                Commands\MakeWebSSO::class,
96✔
43
                Commands\ShowOAuthCallbackUrl::class,
96✔
44
            ]);
96✔
45
        }
46

47
        $this->bootEventHub();
96✔
48
        $this->bootWebSSO();
96✔
49

50
        Event::listen(SocialiteWasCalled::class, NorthwesternAzureExtendSocialite::class);
96✔
51

52
        $ds = new DirectorySearch(EventHub\Guzzle\RetryClient::make());
96✔
53
        $this->app->instance(DirectorySearch::class, $ds);
96✔
54
    } // end boot
55

56
    private function bootWebSSO()
57
    {
58
        $http = EventHub\Guzzle\RetryClient::make();
96✔
59
        $url = (string) config('app.url');
96✔
60
        $sso_config = (array) config('nusoa.sso');
96✔
61

62
        switch (config('nusoa.sso.strategy')) {
96✔
63
            case 'forgerock-direct':
96✔
64
                $sso = new OpenAM11Api($http, $url, $sso_config);
×
65
                $auth_strategy = new OpenAM11($sso);
×
NEW
66
                break;
×
67

68
            default:
69
            case 'apigee':
96✔
70
                $sso = new ApigeeAgentless($http, $url, $sso_config);
96✔
71
                $auth_strategy = new OpenAM11($sso);
96✔
72
                break;
96✔
73
        }
74

75
        $this->app->instance(WebSSO::class, $sso);
96✔
76
        $this->app->instance(WebSSOStrategy::class, $auth_strategy);
96✔
77
    }
78

79
    private function bootEventHub()
80
    {
81
        $classes = [
96✔
82
            EventHub\Queue::class,
96✔
83
            EventHub\DeadLetterQueue::class,
96✔
84
            EventHub\Topic::class,
96✔
85
            EventHub\Message::class,
96✔
86
            EventHub\Webhook::class,
96✔
87
        ];
96✔
88

89
        $args = [
96✔
90
            (string) config('nusoa.eventHub.baseUrl'),
96✔
91
            (string) config('nusoa.eventHub.apiKey'),
96✔
92
            EventHub\Guzzle\RetryClient::make(),
96✔
93
        ];
96✔
94

95
        foreach ($classes as $class) {
96✔
96
            $api = new $class(...$args);
96✔
97
            $this->app->instance($class, $api);
96✔
98
        }
99

100
        $router = $this->app['router'];
96✔
101
        $router->aliasMiddleware('eventhub_hmac', VerifyEventHubHMAC::class);
96✔
102

103
        // This singleton will hold all the routes registered as webhook endpoints
104
        $this->app->singleton(EventHubWebhookRegistration::class, function ($app) {
96✔
105
            return new EventHubWebhookRegistration;
15✔
106
        });
96✔
107

108
        Route::macro('eventHubWebhook', function ($queue, $additional_settings = []) {
96✔
109
            /** @var Route $this */
110
            $url = url($this->uri());
15✔
111

112
            $registry = resolve(EventHubWebhookRegistration::class);
15✔
113
            $registry->registerHookToRoute($queue, $url, $additional_settings);
15✔
114

115
            return $this;
15✔
116
        });
96✔
117
    } // end bootEventHub
118
} // end NuSoaServiceProvider
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc