File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class ScalarController extends Controller
9
9
{
10
10
public function __invoke ()
11
11
{
12
- if (! Gate::check ('viewScalar ' ) && ! app ()->environment ('local ' ) && ! app ()-> environment ( ' testing ' ) ) {
12
+ if (! Gate::check ('viewScalar ' ) && ! app ()->environment ('local ' )) {
13
13
return abort (403 );
14
14
}
15
15
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ use Illuminate \Support \Facades \Gate ;
3
4
use Illuminate \Support \Facades \Route ;
4
5
use Scalar \Controllers \ScalarController ;
5
6
22
23
$ response = $ this ->get (config ('scalar.path ' ));
23
24
24
25
$ response ->assertOk ()
25
- ->assertViewIs ('scalar::reference ' )
26
26
->assertSee ('data-url ' )
27
27
->assertSee (config ('scalar.url ' ));
28
28
});
31
31
$ response = $ this ->get (config ('scalar.path ' ));
32
32
33
33
$ response ->assertOk ()
34
- ->assertViewIs ('scalar::reference ' )
35
34
->assertSee ('https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.json ' );
36
35
});
37
36
45
44
$ response = $ this ->get ('/reference ' );
46
45
47
46
$ response ->assertOk ()
48
- ->assertViewIs ('scalar::reference ' )
49
47
->assertSee ('https://example.com/cdn ' )
50
48
->assertDontSee ($ originalCdn );
51
49
52
50
// Reset config
53
51
config (['scalar.cdn ' => $ originalCdn ]);
54
52
});
53
+
54
+ it ('doesn’t block access in production by default ' , function () {
55
+ $ response = $ this ->get (config ('scalar.path ' ));
56
+
57
+ $ response ->assertOk ();
58
+ });
59
+
60
+ it ('can block access in production ' , function () {
61
+ // Overwrite the viewScalar Gate to block access
62
+ Gate::define ('viewScalar ' , fn ($ user = null ) => false );
63
+
64
+ $ response = $ this ->get (config ('scalar.path ' ));
65
+
66
+ $ response ->assertForbidden ();
67
+ });
You can’t perform that action at this time.
0 commit comments