@@ -33,13 +33,14 @@ private static void SetUpHttpContext(HttpContext context)
33
33
[ Theory ]
34
34
[ ClassData ( typeof ( AuthorizationTestData ) ) ]
35
35
[ ClassData ( typeof ( AuthorizationAttributeTestData ) ) ]
36
- public async Task Policy_NotFound ( Action < IRequestExecutorBuilder > configure )
36
+ public async Task Policy_NotFound ( Action < IRequestExecutorBuilder , int > configure )
37
37
{
38
38
// arrange
39
+ var port = _opaHandle ! . GetPort ( ) ;
39
40
var server = CreateTestServer (
40
41
builder =>
41
42
{
42
- configure ( builder ) ;
43
+ configure ( builder , port ) ;
43
44
builder . Services . AddAuthorization ( ) ;
44
45
} ,
45
46
SetUpHttpContext ) ;
@@ -55,13 +56,14 @@ public async Task Policy_NotFound(Action<IRequestExecutorBuilder> configure)
55
56
[ Theory ]
56
57
[ ClassData ( typeof ( AuthorizationTestData ) ) ]
57
58
[ ClassData ( typeof ( AuthorizationAttributeTestData ) ) ]
58
- public async Task Policy_NotAuthorized ( Action < IRequestExecutorBuilder > configure )
59
+ public async Task Policy_NotAuthorized ( Action < IRequestExecutorBuilder , int > configure )
59
60
{
60
61
// arrange
62
+ var port = _opaHandle ! . GetPort ( ) ;
61
63
var server = CreateTestServer (
62
64
builder =>
63
65
{
64
- configure ( builder ) ;
66
+ configure ( builder , port ) ;
65
67
builder . Services . AddAuthorization ( ) ;
66
68
} ,
67
69
SetUpHttpContext + ( Action < HttpContext > ) ( c =>
@@ -72,7 +74,7 @@ public async Task Policy_NotAuthorized(Action<IRequestExecutorBuilder> configure
72
74
} ) ) ;
73
75
74
76
var hasAgeDefinedPolicy = await File . ReadAllTextAsync ( "Policies/has_age_defined.rego" ) ;
75
- using var client = new HttpClient { BaseAddress = new Uri ( "http://127.0.0.1:8181 " ) , } ;
77
+ using var client = new HttpClient { BaseAddress = new Uri ( $ "http://127.0.0.1:{ port } ") , } ;
76
78
77
79
var putPolicyResponse = await client . PutAsync (
78
80
"/v1/policies/has_age_defined" ,
@@ -90,13 +92,14 @@ public async Task Policy_NotAuthorized(Action<IRequestExecutorBuilder> configure
90
92
[ Theory ]
91
93
[ ClassData ( typeof ( AuthorizationTestData ) ) ]
92
94
[ ClassData ( typeof ( AuthorizationAttributeTestData ) ) ]
93
- public async Task Policy_Authorized ( Action < IRequestExecutorBuilder > configure )
95
+ public async Task Policy_Authorized ( Action < IRequestExecutorBuilder , int > configure )
94
96
{
95
97
// arrange
98
+ var port = _opaHandle ! . GetPort ( ) ;
96
99
var server = CreateTestServer (
97
100
builder =>
98
101
{
99
- configure ( builder ) ;
102
+ configure ( builder , port ) ;
100
103
builder . Services . AddAuthorization ( ) ;
101
104
} ,
102
105
SetUpHttpContext + ( Action < HttpContext > ) ( c =>
@@ -108,7 +111,7 @@ public async Task Policy_Authorized(Action<IRequestExecutorBuilder> configure)
108
111
} ) ) ;
109
112
110
113
var hasAgeDefinedPolicy = await File . ReadAllTextAsync ( "Policies/has_age_defined.rego" ) ;
111
- using var client = new HttpClient { BaseAddress = new Uri ( "http://127.0.0.1:8181 " ) , } ;
114
+ using var client = new HttpClient { BaseAddress = new Uri ( $ "http://127.0.0.1:{ port } ") , } ;
112
115
113
116
var putPolicyResponse = await client . PutAsync (
114
117
"/v1/policies/has_age_defined" ,
@@ -126,13 +129,14 @@ public async Task Policy_Authorized(Action<IRequestExecutorBuilder> configure)
126
129
[ Theory ]
127
130
[ ClassData ( typeof ( AuthorizationTestData ) ) ]
128
131
[ ClassData ( typeof ( AuthorizationAttributeTestData ) ) ]
129
- public async Task Policy_Authorized_WithExtensions ( Action < IRequestExecutorBuilder > configure )
132
+ public async Task Policy_Authorized_WithExtensions ( Action < IRequestExecutorBuilder , int > configure )
130
133
{
131
134
// arrange
135
+ var port = _opaHandle ! . GetPort ( ) ;
132
136
var server = CreateTestServer (
133
137
builder =>
134
138
{
135
- configure ( builder ) ;
139
+ configure ( builder , port ) ;
136
140
builder . Services . AddAuthorization ( ) ;
137
141
builder . AddOpaQueryRequestExtensionsHandler ( Policies . HasDefinedAge ,
138
142
context => context . Resource is IMiddlewareContext or AuthorizationContext
@@ -151,7 +155,7 @@ public async Task Policy_Authorized_WithExtensions(Action<IRequestExecutorBuilde
151
155
} ) ) ;
152
156
153
157
var hasAgeDefinedPolicy = await File . ReadAllTextAsync ( "Policies/has_age_defined.rego" ) ;
154
- using var client = new HttpClient { BaseAddress = new Uri ( "http://127.0.0.1:8181 " ) , } ;
158
+ using var client = new HttpClient { BaseAddress = new Uri ( $ "http://127.0.0.1:{ port } ") , } ;
155
159
156
160
var putPolicyResponse = await client . PutAsync (
157
161
"/v1/policies/has_age_defined" ,
0 commit comments