@@ -8,181 +8,6 @@ namespace Azure.Monitor.OpenTelemetry.Exporter
8
8
{
9
9
public class HttpHelperTests
10
10
{
11
- [ Fact ]
12
- public void GetUrl_Null ( )
13
- {
14
- var PartBTags = AzMonList . Initialize ( ) ;
15
-
16
- PartBTags . GenerateUrlAndAuthority ( out var url , out var urlAuthority ) ;
17
- Assert . Null ( url ) ;
18
- Assert . Null ( urlAuthority ) ;
19
- }
20
-
21
- [ Theory ]
22
- [ InlineData ( SemanticConventions . AttributeHttpUrl ) ]
23
- [ InlineData ( SemanticConventions . AttributeHttpScheme ) ]
24
- [ InlineData ( SemanticConventions . AttributeHttpHost ) ]
25
- public void GetUrl_NullOrEmpty ( string attribute )
26
- {
27
- var PartBTags = AzMonList . Initialize ( ) ;
28
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( attribute , null ) ) ;
29
-
30
- PartBTags . GenerateUrlAndAuthority ( out var url , out var urlAuthority ) ;
31
- Assert . Null ( url ) ;
32
- Assert . Null ( urlAuthority ) ;
33
-
34
- AzMonList . Clear ( ref PartBTags ) ;
35
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( attribute , string . Empty ) ) ;
36
- PartBTags . GenerateUrlAndAuthority ( out url , out urlAuthority ) ;
37
- Assert . Null ( url ) ;
38
- Assert . Null ( urlAuthority ) ;
39
- }
40
-
41
- [ Fact ]
42
- public void GetUrl_With_HttpScheme_And_Null_HttpHost ( )
43
- {
44
- var PartBTags = AzMonList . Initialize ( ) ;
45
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpScheme , null ) ) ;
46
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpHost , null ) ) ;
47
-
48
- PartBTags . GenerateUrlAndAuthority ( out var url , out var urlAuthority ) ;
49
- Assert . Null ( url ) ;
50
- Assert . Null ( urlAuthority ) ;
51
- }
52
-
53
- [ Theory ]
54
- [ InlineData ( "https" , null , null ) ]
55
- [ InlineData ( "https" , "" , null ) ]
56
- [ InlineData ( "https" , "netpeername" , null ) ]
57
- public void GetUrl_NetPeerName_NullOrEmpty ( string scheme , string peerName , string peerPort )
58
- {
59
- var PartBTags = AzMonList . Initialize ( ) ;
60
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpScheme , scheme ) ) ;
61
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeNetPeerName , peerName ) ) ;
62
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeNetPeerPort , peerPort ) ) ;
63
-
64
- PartBTags . GenerateUrlAndAuthority ( out var url , out var urlAuthority ) ;
65
-
66
- if ( string . IsNullOrEmpty ( peerName ) )
67
- {
68
- Assert . Null ( url ) ;
69
- Assert . Null ( urlAuthority ) ;
70
- }
71
- else
72
- {
73
- Assert . Equal ( "https://netpeername" , url ) ;
74
- Assert . Equal ( "netpeername" , urlAuthority ) ;
75
- }
76
- }
77
-
78
- [ Theory ]
79
- [ InlineData ( "https" , "localhost" , null ) ]
80
- [ InlineData ( "https" , "localhost" , "80" ) ]
81
- [ InlineData ( "https" , "localhost" , "443" ) ]
82
- public void GetUrl_HttpPort_NullEmptyOrDefault ( string scheme , string httpHost , string hostPort )
83
- {
84
- var PartBTags = AzMonList . Initialize ( ) ;
85
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpScheme , scheme ) ) ;
86
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpHost , httpHost ) ) ;
87
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpHostPort , hostPort ) ) ;
88
-
89
- PartBTags . GenerateUrlAndAuthority ( out var url , out var urlAuthority ) ;
90
-
91
- Assert . Equal ( "https://localhost" , url ) ;
92
- Assert . Equal ( "localhost" , urlAuthority ) ;
93
- }
94
-
95
- [ Theory ]
96
- [ InlineData ( "https" , "localhost" , "8888" , null ) ]
97
- [ InlineData ( "http" , "localhost" , "80" , "/test" ) ]
98
- [ InlineData ( "https" , "localhost" , "443" , "/test" ) ]
99
- [ InlineData ( "https" , "localhost" , "8888" , "/test" ) ]
100
- public void GetUrl_HttpPort_RandomPort_With_HttpTarget ( string scheme , string httpHost , string hostPort , string target )
101
- {
102
- var PartBTags = AzMonList . Initialize ( ) ;
103
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpScheme , scheme ) ) ;
104
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpHost , httpHost ) ) ;
105
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpHostPort , hostPort ) ) ;
106
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpTarget , target ) ) ;
107
-
108
- PartBTags . GenerateUrlAndAuthority ( out var url , out var urlAuthority ) ;
109
-
110
- hostPort = hostPort == "8888" ? ":8888" : null ;
111
- Assert . Equal ( $ "{ scheme } ://localhost{ hostPort } { target } ", url ) ;
112
- Assert . Equal ( $ "localhost{ hostPort } ", urlAuthority ) ;
113
- }
114
-
115
- [ Theory ]
116
- [ InlineData ( "https" , "10.0.0.1" , "443" , null ) ]
117
- [ InlineData ( "https" , "10.0.0.1" , "443" , "/test" ) ]
118
- public void GetUrl_NetPeerIP_Success ( string scheme , string peerIp , string peerPort , string target )
119
- {
120
- var PartBTags = AzMonList . Initialize ( ) ;
121
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpScheme , scheme ) ) ;
122
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeNetPeerIp , peerIp ) ) ;
123
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeNetPeerPort , peerPort ) ) ;
124
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpTarget , target ) ) ;
125
-
126
- PartBTags . GenerateUrlAndAuthority ( out var url , out var urlAuthority ) ;
127
-
128
- Assert . Equal ( $ "https://10.0.0.1:443{ target } ", url ) ;
129
- Assert . Equal ( "10.0.0.1:443" , urlAuthority ) ;
130
- }
131
-
132
- [ Theory ]
133
- [ InlineData ( "https" , "localhost" , "443" , null ) ]
134
- [ InlineData ( "https" , "localhost" , "443" , "/test" ) ]
135
- public void GetUrl_NetPeerName_Success ( string scheme , string peerName , string peerPort , string target )
136
- {
137
- var PartBTags = AzMonList . Initialize ( ) ;
138
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpScheme , scheme ) ) ;
139
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeNetPeerName , peerName ) ) ;
140
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeNetPeerPort , peerPort ) ) ;
141
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpTarget , target ) ) ;
142
-
143
- PartBTags . GenerateUrlAndAuthority ( out var url , out var urlAuthority ) ;
144
- Assert . Equal ( $ "https://localhost:443{ target } ", url ) ;
145
- Assert . Equal ( $ "localhost:443", urlAuthority ) ;
146
- }
147
-
148
- [ Theory ]
149
- [ InlineData ( "localhost" , "" , "" ) ]
150
- [ InlineData ( "localhost" , "8888" , "" ) ]
151
- [ InlineData ( "localhost" , "8888" , "/test" ) ]
152
- [ InlineData ( "localhost" , null , null ) ]
153
- public void GetUrl_HttpHost_Success ( string httpHost , string hostPort , string target )
154
- {
155
- var PartBTags = AzMonList . Initialize ( ) ;
156
-
157
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpHost , httpHost ) ) ;
158
-
159
- if ( hostPort != "" )
160
- {
161
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpHostPort , hostPort ) ) ;
162
- }
163
-
164
- if ( target != "" )
165
- {
166
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpTarget , target ) ) ;
167
- }
168
-
169
- PartBTags . GenerateUrlAndAuthority ( out var url , out var urlAuthority ) ;
170
- hostPort = hostPort == "8888" ? ":8888" : null ;
171
- Assert . Equal ( $ "localhost{ hostPort } { target } ", url ) ;
172
- Assert . Equal ( $ "localhost{ hostPort } ", urlAuthority ) ;
173
- }
174
-
175
- [ Fact ]
176
- public void GetUrl_HttpUrl_Success ( )
177
- {
178
- var PartBTags = AzMonList . Initialize ( ) ;
179
- AzMonList . Add ( ref PartBTags , new KeyValuePair < string , object > ( SemanticConventions . AttributeHttpUrl , "https://www.wiki.com" ) ) ;
180
-
181
- PartBTags . GenerateUrlAndAuthority ( out var url , out var urlAuthority ) ;
182
- Assert . Equal ( "https://www.wiki.com/" , url ) ;
183
- Assert . Equal ( "www.wiki.com" , urlAuthority ) ;
184
- }
185
-
186
11
[ Fact ]
187
12
public void HttpRequestUrlIsSetUsingHttpUrl ( )
188
13
{
0 commit comments