github.com/zmap/zlint@v1.1.0/util/fqdn_test.go (about)

     1  /*
     2   * ZLint Copyright 2018 Regents of the University of Michigan
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
     5   * use this file except in compliance with the License. You may obtain a copy
     6   * of the License at http://www.apache.org/licenses/LICENSE-2.0
     7   *
     8   * Unless required by applicable law or agreed to in writing, software
     9   * distributed under the License is distributed on an "AS IS" BASIS,
    10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
    11   * implied. See the License for the specific language governing
    12   * permissions and limitations under the License.
    13   */
    14  
    15  package util
    16  
    17  import (
    18  	"testing"
    19  )
    20  
    21  func TestIsFQDNCorrectFQDN(t *testing.T) {
    22  	domain := "google.com"
    23  	expected := true
    24  	actual := IsFQDN(domain)
    25  	if expected != actual {
    26  		t.Error(
    27  			"For", domain,
    28  			"expected", expected,
    29  			"got", actual,
    30  		)
    31  	}
    32  }
    33  
    34  func TestIsFQDNQuestionMarkFQDN(t *testing.T) {
    35  	domain := "?.?.abc.com"
    36  	expected := true
    37  	actual := IsFQDN(domain)
    38  	if expected != actual {
    39  		t.Error(
    40  			"For", domain,
    41  			"expected", expected,
    42  			"got", actual,
    43  		)
    44  	}
    45  }
    46  
    47  func TestIsFQDNQuestionMarkIncorrectPlaceFQDN(t *testing.T) {
    48  	domain := "?.?.abc?.com"
    49  	expected := false
    50  	actual := IsFQDN(domain)
    51  	if expected != actual {
    52  		t.Error(
    53  			"For", domain,
    54  			"expected", expected,
    55  			"got", actual,
    56  		)
    57  	}
    58  }
    59  
    60  func TestIsFQDNManyQuestionMarksFQDN(t *testing.T) {
    61  	domain := "?.?.?.?.?.?.?.abc.com"
    62  	expected := true
    63  	actual := IsFQDN(domain)
    64  	if expected != actual {
    65  		t.Error(
    66  			"For", domain,
    67  			"expected", expected,
    68  			"got", actual,
    69  		)
    70  	}
    71  }
    72  
    73  func TestIsFQDNWildcardFQDN(t *testing.T) {
    74  	domain := "*.abc.com"
    75  	expected := true
    76  	actual := IsFQDN(domain)
    77  	if expected != actual {
    78  		t.Error(
    79  			"For", domain,
    80  			"expected", expected,
    81  			"got", actual,
    82  		)
    83  	}
    84  }
    85  
    86  func TestIsFQDNNotFQDN(t *testing.T) {
    87  	domain := "abc"
    88  	expected := false
    89  	actual := IsFQDN(domain)
    90  	if expected != actual {
    91  		t.Error(
    92  			"For", domain,
    93  			"expected", expected,
    94  			"got", actual,
    95  		)
    96  	}
    97  }
    98  
    99  func TestGetAuthorityBadURI(t *testing.T) {
   100  	uri := "not//a/valid/uri"
   101  	expected := ""
   102  	actual := GetAuthority(uri)
   103  	if expected != actual {
   104  		t.Error(
   105  			"For", uri,
   106  			"expected", expected,
   107  			"got", actual,
   108  		)
   109  	}
   110  }
   111  
   112  func TestGetHostBadURI(t *testing.T) {
   113  	uri := "not//a/valid/uri"
   114  	expected := ""
   115  	authority := GetAuthority(uri)
   116  	actual := GetHost(authority)
   117  	if expected != actual {
   118  		t.Error(
   119  			"For", uri,
   120  			"expected", expected,
   121  			"got", actual,
   122  		)
   123  	}
   124  }
   125  
   126  func TestGetAuthorityRootless(t *testing.T) {
   127  	uri := "sip:user@host.com"
   128  	expected := ""
   129  	actual := GetAuthority(uri)
   130  	if expected != actual {
   131  		t.Error(
   132  			"For", uri,
   133  			"expected", expected,
   134  			"got", actual,
   135  		)
   136  	}
   137  }
   138  
   139  func TestGetHostRootless(t *testing.T) {
   140  	uri := "sip:user@host.com"
   141  	expected := ""
   142  	actual := GetAuthority(uri)
   143  	if expected != actual {
   144  		t.Error(
   145  			"For", uri,
   146  			"expected", expected,
   147  			"got", actual,
   148  		)
   149  	}
   150  }
   151  
   152  func TestGetAuthorityNoUserinfoNoPortNoAbsolutePathNoQueryNoFragment(t *testing.T) {
   153  	uri := "scheme://host.com"
   154  	expected := "host.com"
   155  	actual := GetAuthority(uri)
   156  	if expected != actual {
   157  		t.Error(
   158  			"For", uri,
   159  			"expected", expected,
   160  			"got", actual,
   161  		)
   162  	}
   163  }
   164  
   165  func TestGetHostNoUserinfoNoPortNoAbsolutePathNoQueryNoFragment(t *testing.T) {
   166  	uri := "scheme://host.com"
   167  	expected := "host.com"
   168  	authority := GetAuthority(uri)
   169  	actual := GetHost(authority)
   170  	if expected != actual {
   171  		t.Error(
   172  			"For", uri,
   173  			"expected", expected,
   174  			"got", actual,
   175  		)
   176  	}
   177  }
   178  
   179  func TestGetAuthorityWithUserinfoNoPortNoAbsolutePathNoQueryNoFragment(t *testing.T) {
   180  	uri := "scheme://user@host.com"
   181  	expected := "user@host.com"
   182  	actual := GetAuthority(uri)
   183  	if expected != actual {
   184  		t.Error(
   185  			"For", uri,
   186  			"expected", expected,
   187  			"got", actual,
   188  		)
   189  	}
   190  }
   191  
   192  func TestGetHostWithUserinfoNoPortNoAbsolutePathNoQueryNoFragment(t *testing.T) {
   193  	uri := "scheme://user@host.com"
   194  	expected := "host.com"
   195  	authority := GetAuthority(uri)
   196  	actual := GetHost(authority)
   197  	if expected != actual {
   198  		t.Error(
   199  			"For", uri,
   200  			"expected", expected,
   201  			"got", actual,
   202  		)
   203  	}
   204  }
   205  
   206  func TestGetAuthorityNoUserinfoWithPortNoAbsolutePathNoQueryNoFragment(t *testing.T) {
   207  	uri := "scheme://host.com:123"
   208  	expected := "host.com:123"
   209  	actual := GetAuthority(uri)
   210  	if expected != actual {
   211  		t.Error(
   212  			"For", uri,
   213  			"expected", expected,
   214  			"got", actual,
   215  		)
   216  	}
   217  }
   218  
   219  func TestGetHostNoUserinfoWithPortNoAbsolutePathNoQueryNoFragment(t *testing.T) {
   220  	uri := "scheme://host.com:123"
   221  	expected := "host.com"
   222  	authority := GetAuthority(uri)
   223  	actual := GetHost(authority)
   224  	if expected != actual {
   225  		t.Error(
   226  			"For", uri,
   227  			"expected", expected,
   228  			"got", actual,
   229  		)
   230  	}
   231  }
   232  
   233  func TestGetAuthorityWithUserinfoWithPortNoAbsolutePathNoQueryNoFragment(t *testing.T) {
   234  	uri := "scheme://user@host.com:123"
   235  	expected := "user@host.com:123"
   236  	actual := GetAuthority(uri)
   237  	if expected != actual {
   238  		t.Error(
   239  			"For", uri,
   240  			"expected", expected,
   241  			"got", actual,
   242  		)
   243  	}
   244  }
   245  
   246  func TestGetHostWithUserinfoWithPortNoAbsolutePathNoQueryNoFragment(t *testing.T) {
   247  	uri := "scheme://user@host.com:123"
   248  	expected := "host.com"
   249  	authority := GetAuthority(uri)
   250  	actual := GetHost(authority)
   251  	if expected != actual {
   252  		t.Error(
   253  			"For", uri,
   254  			"expected", expected,
   255  			"got", actual,
   256  		)
   257  	}
   258  }
   259  
   260  func TestGetAuthorityNoUserinfoNoPortWithAbsolutePathNoQueryNoFragment(t *testing.T) {
   261  	uri := "scheme://host.com/path/to/something"
   262  	expected := "host.com"
   263  	actual := GetAuthority(uri)
   264  	if expected != actual {
   265  		t.Error(
   266  			"For", uri,
   267  			"expected", expected,
   268  			"got", actual,
   269  		)
   270  	}
   271  }
   272  
   273  func TestGetHostNoUserinfoNoPortWithAbsolutePathNoQueryNoFragment(t *testing.T) {
   274  	uri := "scheme://host.com/path/to/something"
   275  	expected := "host.com"
   276  	authority := GetAuthority(uri)
   277  	actual := GetHost(authority)
   278  	if expected != actual {
   279  		t.Error(
   280  			"For", uri,
   281  			"expected", expected,
   282  			"got", actual,
   283  		)
   284  	}
   285  }
   286  
   287  func TestGetAuthorityWithUserinfoNoPortWithAbsolutePathNoQueryNoFragment(t *testing.T) {
   288  	uri := "scheme://user@host.com/path/to/something"
   289  	expected := "user@host.com"
   290  	actual := GetAuthority(uri)
   291  	if expected != actual {
   292  		t.Error(
   293  			"For", uri,
   294  			"expected", expected,
   295  			"got", actual,
   296  		)
   297  	}
   298  }
   299  
   300  func TestGetHostWithUserinfoNoPortWithAbsolutePathNoQueryNoFragment(t *testing.T) {
   301  	uri := "scheme://user@host.com/path/to/something"
   302  	expected := "host.com"
   303  	authority := GetAuthority(uri)
   304  	actual := GetHost(authority)
   305  	if expected != actual {
   306  		t.Error(
   307  			"For", uri,
   308  			"expected", expected,
   309  			"got", actual,
   310  		)
   311  	}
   312  }
   313  
   314  func TestGetAuthorityNoUserinfoWithPortWithAbsolutePathNoQueryNoFragment(t *testing.T) {
   315  	uri := "scheme://host.com:123/path/to/something"
   316  	expected := "host.com:123"
   317  	actual := GetAuthority(uri)
   318  	if expected != actual {
   319  		t.Error(
   320  			"For", uri,
   321  			"expected", expected,
   322  			"got", actual,
   323  		)
   324  	}
   325  }
   326  
   327  func TestGetHostNoUserinfoWithPortWithAbsolutePathNoQueryNoFragment(t *testing.T) {
   328  	uri := "scheme://host.com:123/path/to/something"
   329  	expected := "host.com"
   330  	authority := GetAuthority(uri)
   331  	actual := GetHost(authority)
   332  	if expected != actual {
   333  		t.Error(
   334  			"For", uri,
   335  			"expected", expected,
   336  			"got", actual,
   337  		)
   338  	}
   339  }
   340  
   341  func TestGetAuthorityWithUserinfoWithPortWithAbsolutePathNoQueryNoFragment(t *testing.T) {
   342  	uri := "scheme://user@host.com:123/path/to/something"
   343  	expected := "user@host.com:123"
   344  	actual := GetAuthority(uri)
   345  	if expected != actual {
   346  		t.Error(
   347  			"For", uri,
   348  			"expected", expected,
   349  			"got", actual,
   350  		)
   351  	}
   352  }
   353  
   354  func TestGetHostWithUserinfoWithPortWithAbsolutePathNoQueryNoFragment(t *testing.T) {
   355  	uri := "scheme://user@host.com:123/path/to/something"
   356  	expected := "host.com"
   357  	authority := GetAuthority(uri)
   358  	actual := GetHost(authority)
   359  	if expected != actual {
   360  		t.Error(
   361  			"For", uri,
   362  			"expected", expected,
   363  			"got", actual,
   364  		)
   365  	}
   366  }
   367  
   368  func TestGetAuthorityNoUserinfoNoPortNoAbsolutePathWithQueryNoFragment(t *testing.T) {
   369  	uri := "scheme://host.com?query=something"
   370  	expected := "host.com"
   371  	actual := GetAuthority(uri)
   372  	if expected != actual {
   373  		t.Error(
   374  			"For", uri,
   375  			"expected", expected,
   376  			"got", actual,
   377  		)
   378  	}
   379  }
   380  
   381  func TestGetHostNoUserinfoNoPortNoAbsolutePathWithQueryNoFragment(t *testing.T) {
   382  	uri := "scheme://host.com?query=something"
   383  	expected := "host.com"
   384  	authority := GetAuthority(uri)
   385  	actual := GetHost(authority)
   386  	if expected != actual {
   387  		t.Error(
   388  			"For", uri,
   389  			"expected", expected,
   390  			"got", actual,
   391  		)
   392  	}
   393  }
   394  
   395  func TestGetAuthorityWithUserinfoNoPortNoAbsolutePathWithQueryNoFragment(t *testing.T) {
   396  	uri := "scheme://user@host.com?query=something"
   397  	expected := "user@host.com"
   398  	actual := GetAuthority(uri)
   399  	if expected != actual {
   400  		t.Error(
   401  			"For", uri,
   402  			"expected", expected,
   403  			"got", actual,
   404  		)
   405  	}
   406  }
   407  
   408  func TestGetHostWithUserinfoNoPortNoAbsolutePathWithQueryNoFragment(t *testing.T) {
   409  	uri := "scheme://user@host.com?query=something"
   410  	expected := "host.com"
   411  	authority := GetAuthority(uri)
   412  	actual := GetHost(authority)
   413  	if expected != actual {
   414  		t.Error(
   415  			"For", uri,
   416  			"expected", expected,
   417  			"got", actual,
   418  		)
   419  	}
   420  }
   421  
   422  func TestGetAuthorityNoUserinfoWithPortNoAbsolutePathWithQueryNoFragment(t *testing.T) {
   423  	uri := "scheme://host.com:123?query=something"
   424  	expected := "host.com:123"
   425  	actual := GetAuthority(uri)
   426  	if expected != actual {
   427  		t.Error(
   428  			"For", uri,
   429  			"expected", expected,
   430  			"got", actual,
   431  		)
   432  	}
   433  }
   434  
   435  func TestGetHostNoUserinfoWithPortNoAbsolutePathWithQueryNoFragment(t *testing.T) {
   436  	uri := "scheme://host.com:123?query=something"
   437  	expected := "host.com"
   438  	authority := GetAuthority(uri)
   439  	actual := GetHost(authority)
   440  	if expected != actual {
   441  		t.Error(
   442  			"For", uri,
   443  			"expected", expected,
   444  			"got", actual,
   445  		)
   446  	}
   447  }
   448  
   449  func TestGetAuthorityWithUserinfoWithPortNoAbsolutePathWithQueryNoFragment(t *testing.T) {
   450  	uri := "scheme://user@host.com:123?query=something"
   451  	expected := "user@host.com:123"
   452  	actual := GetAuthority(uri)
   453  	if expected != actual {
   454  		t.Error(
   455  			"For", uri,
   456  			"expected", expected,
   457  			"got", actual,
   458  		)
   459  	}
   460  }
   461  
   462  func TestGetHostWithUserinfoWithPortNoAbsolutePathWithQueryNoFragment(t *testing.T) {
   463  	uri := "scheme://user@host.com:123?query=something"
   464  	expected := "host.com"
   465  	authority := GetAuthority(uri)
   466  	actual := GetHost(authority)
   467  	if expected != actual {
   468  		t.Error(
   469  			"For", uri,
   470  			"expected", expected,
   471  			"got", actual,
   472  		)
   473  	}
   474  }
   475  
   476  func TestGetAuthorityNoUserinfoNoPortWithAbsolutePathWithQueryNoFragment(t *testing.T) {
   477  	uri := "scheme://host.com/path/to/something?query=something"
   478  	expected := "host.com"
   479  	actual := GetAuthority(uri)
   480  	if expected != actual {
   481  		t.Error(
   482  			"For", uri,
   483  			"expected", expected,
   484  			"got", actual,
   485  		)
   486  	}
   487  }
   488  
   489  func TestGetHostNoUserinfoNoPortWithAbsolutePathWithQueryNoFragment(t *testing.T) {
   490  	uri := "scheme://host.com/path/to/something?query=something"
   491  	expected := "host.com"
   492  	authority := GetAuthority(uri)
   493  	actual := GetHost(authority)
   494  	if expected != actual {
   495  		t.Error(
   496  			"For", uri,
   497  			"expected", expected,
   498  			"got", actual,
   499  		)
   500  	}
   501  }
   502  
   503  func TestGetAuthorityWithUserinfoNoPortWithAbsolutePathWithQueryNoFragment(t *testing.T) {
   504  	uri := "scheme://user@host.com/path/to/something?query=something"
   505  	expected := "user@host.com"
   506  	actual := GetAuthority(uri)
   507  	if expected != actual {
   508  		t.Error(
   509  			"For", uri,
   510  			"expected", expected,
   511  			"got", actual,
   512  		)
   513  	}
   514  }
   515  
   516  func TestGetHostWithUserinfoNoPortWithAbsolutePathWithQueryNoFragment(t *testing.T) {
   517  	uri := "scheme://user@host.com/path/to/something?query=something"
   518  	expected := "host.com"
   519  	authority := GetAuthority(uri)
   520  	actual := GetHost(authority)
   521  	if expected != actual {
   522  		t.Error(
   523  			"For", uri,
   524  			"expected", expected,
   525  			"got", actual,
   526  		)
   527  	}
   528  }
   529  
   530  func TestGetAuthorityNoUserinfoWithPortWithAbsolutePathWithQueryNoFragment(t *testing.T) {
   531  	uri := "scheme://host.com:123/path/to/something?query=something"
   532  	expected := "host.com:123"
   533  	actual := GetAuthority(uri)
   534  	if expected != actual {
   535  		t.Error(
   536  			"For", uri,
   537  			"expected", expected,
   538  			"got", actual,
   539  		)
   540  	}
   541  }
   542  
   543  func TestGetHostNoUserinfoWithPortWithAbsolutePathWithQueryNoFragment(t *testing.T) {
   544  	uri := "scheme://host.com:123/path/to/something?query=something"
   545  	expected := "host.com"
   546  	authority := GetAuthority(uri)
   547  	actual := GetHost(authority)
   548  	if expected != actual {
   549  		t.Error(
   550  			"For", uri,
   551  			"expected", expected,
   552  			"got", actual,
   553  		)
   554  	}
   555  }
   556  
   557  func TestGetAuthorityWithUserinfoWithPortWithAbsolutePathWithQueryNoFragment(t *testing.T) {
   558  	uri := "scheme://user@host.com:123/path/to/something?query=something"
   559  	expected := "user@host.com:123"
   560  	actual := GetAuthority(uri)
   561  	if expected != actual {
   562  		t.Error(
   563  			"For", uri,
   564  			"expected", expected,
   565  			"got", actual,
   566  		)
   567  	}
   568  }
   569  
   570  func TestGetHostWithUserinfoWithPortWithAbsolutePathWithQueryNoFragment(t *testing.T) {
   571  	uri := "scheme://user@host.com:123/path/to/something?query=something"
   572  	expected := "host.com"
   573  	authority := GetAuthority(uri)
   574  	actual := GetHost(authority)
   575  	if expected != actual {
   576  		t.Error(
   577  			"For", uri,
   578  			"expected", expected,
   579  			"got", actual,
   580  		)
   581  	}
   582  }
   583  
   584  func TestGetAuthorityNoUserinfoNoPortNoAbsolutePathNoQueryWithFragment(t *testing.T) {
   585  	uri := "scheme://host.com#fragment"
   586  	expected := "host.com"
   587  	actual := GetAuthority(uri)
   588  	if expected != actual {
   589  		t.Error(
   590  			"For", uri,
   591  			"expected", expected,
   592  			"got", actual,
   593  		)
   594  	}
   595  }
   596  
   597  func TestGetHostNoUserinfoNoPortNoAbsolutePathNoQueryWithFragment(t *testing.T) {
   598  	uri := "scheme://host.com#fragment"
   599  	expected := "host.com"
   600  	authority := GetAuthority(uri)
   601  	actual := GetHost(authority)
   602  	if expected != actual {
   603  		t.Error(
   604  			"For", uri,
   605  			"expected", expected,
   606  			"got", actual,
   607  		)
   608  	}
   609  }
   610  
   611  func TestGetAuthorityWithUserinfoNoPortNoAbsolutePathNoQueryWithFragment(t *testing.T) {
   612  	uri := "scheme://user@host.com#fragment"
   613  	expected := "user@host.com"
   614  	actual := GetAuthority(uri)
   615  	if expected != actual {
   616  		t.Error(
   617  			"For", uri,
   618  			"expected", expected,
   619  			"got", actual,
   620  		)
   621  	}
   622  }
   623  
   624  func TestGetHostWithUserinfoNoPortNoAbsolutePathNoQueryWithFragment(t *testing.T) {
   625  	uri := "scheme://user@host.com#fragment"
   626  	expected := "host.com"
   627  	authority := GetAuthority(uri)
   628  	actual := GetHost(authority)
   629  	if expected != actual {
   630  		t.Error(
   631  			"For", uri,
   632  			"expected", expected,
   633  			"got", actual,
   634  		)
   635  	}
   636  }
   637  
   638  func TestGetAuthorityNoUserinfoWithPortNoAbsolutePathNoQueryWithFragment(t *testing.T) {
   639  	uri := "scheme://host.com:123#fragment"
   640  	expected := "host.com:123"
   641  	actual := GetAuthority(uri)
   642  	if expected != actual {
   643  		t.Error(
   644  			"For", uri,
   645  			"expected", expected,
   646  			"got", actual,
   647  		)
   648  	}
   649  }
   650  
   651  func TestGetHostNoUserinfoWithPortNoAbsolutePathNoQueryWithFragment(t *testing.T) {
   652  	uri := "scheme://host.com:123#fragment"
   653  	expected := "host.com"
   654  	authority := GetAuthority(uri)
   655  	actual := GetHost(authority)
   656  	if expected != actual {
   657  		t.Error(
   658  			"For", uri,
   659  			"expected", expected,
   660  			"got", actual,
   661  		)
   662  	}
   663  }
   664  
   665  func TestGetAuthorityWithUserinfoWithPortNoAbsolutePathNoQueryWithFragment(t *testing.T) {
   666  	uri := "scheme://user@host.com:123#fragment"
   667  	expected := "user@host.com:123"
   668  	actual := GetAuthority(uri)
   669  	if expected != actual {
   670  		t.Error(
   671  			"For", uri,
   672  			"expected", expected,
   673  			"got", actual,
   674  		)
   675  	}
   676  }
   677  
   678  func TestGetHostWithUserinfoWithPortNoAbsolutePathNoQueryWithFragment(t *testing.T) {
   679  	uri := "scheme://user@host.com:123#fragment"
   680  	expected := "host.com"
   681  	authority := GetAuthority(uri)
   682  	actual := GetHost(authority)
   683  	if expected != actual {
   684  		t.Error(
   685  			"For", uri,
   686  			"expected", expected,
   687  			"got", actual,
   688  		)
   689  	}
   690  }
   691  
   692  func TestGetAuthorityNoUserinfoNoPortWithAbsolutePathNoQueryWithFragment(t *testing.T) {
   693  	uri := "scheme://host.com/path/to/something#fragment"
   694  	expected := "host.com"
   695  	actual := GetAuthority(uri)
   696  	if expected != actual {
   697  		t.Error(
   698  			"For", uri,
   699  			"expected", expected,
   700  			"got", actual,
   701  		)
   702  	}
   703  }
   704  
   705  func TestGetHostNoUserinfoNoPortWithAbsolutePathNoQueryWithFragment(t *testing.T) {
   706  	uri := "scheme://host.com/path/to/something#fragment"
   707  	expected := "host.com"
   708  	authority := GetAuthority(uri)
   709  	actual := GetHost(authority)
   710  	if expected != actual {
   711  		t.Error(
   712  			"For", uri,
   713  			"expected", expected,
   714  			"got", actual,
   715  		)
   716  	}
   717  }
   718  
   719  func TestGetAuthorityWithUserinfoNoPortWithAbsolutePathNoQueryWithFragment(t *testing.T) {
   720  	uri := "scheme://user@host.com/path/to/something#fragment"
   721  	expected := "user@host.com"
   722  	actual := GetAuthority(uri)
   723  	if expected != actual {
   724  		t.Error(
   725  			"For", uri,
   726  			"expected", expected,
   727  			"got", actual,
   728  		)
   729  	}
   730  }
   731  
   732  func TestGetHostWithUserinfoNoPortWithAbsolutePathNoQueryWithFragment(t *testing.T) {
   733  	uri := "scheme://user@host.com/path/to/something#fragment"
   734  	expected := "host.com"
   735  	authority := GetAuthority(uri)
   736  	actual := GetHost(authority)
   737  	if expected != actual {
   738  		t.Error(
   739  			"For", uri,
   740  			"expected", expected,
   741  			"got", actual,
   742  		)
   743  	}
   744  }
   745  
   746  func TestGetAuthorityNoUserinfoWithPortWithAbsolutePathNoQueryWithFragment(t *testing.T) {
   747  	uri := "scheme://host.com:123/path/to/something#fragment"
   748  	expected := "host.com:123"
   749  	actual := GetAuthority(uri)
   750  	if expected != actual {
   751  		t.Error(
   752  			"For", uri,
   753  			"expected", expected,
   754  			"got", actual,
   755  		)
   756  	}
   757  }
   758  
   759  func TestGetHostNoUserinfoWithPortWithAbsolutePathNoQueryWithFragment(t *testing.T) {
   760  	uri := "scheme://host.com:123/path/to/something#fragment"
   761  	expected := "host.com"
   762  	authority := GetAuthority(uri)
   763  	actual := GetHost(authority)
   764  	if expected != actual {
   765  		t.Error(
   766  			"For", uri,
   767  			"expected", expected,
   768  			"got", actual,
   769  		)
   770  	}
   771  }
   772  
   773  func TestGetAuthorityWithUserinfoWithPortWithAbsolutePathNoQueryWithFragment(t *testing.T) {
   774  	uri := "scheme://user@host.com:123/path/to/something#fragment"
   775  	expected := "user@host.com:123"
   776  	actual := GetAuthority(uri)
   777  	if expected != actual {
   778  		t.Error(
   779  			"For", uri,
   780  			"expected", expected,
   781  			"got", actual,
   782  		)
   783  	}
   784  }
   785  
   786  func TestGetHostWithUserinfoWithPortWithAbsolutePathNoQueryWithFragment(t *testing.T) {
   787  	uri := "scheme://user@host.com:123/path/to/something#fragment"
   788  	expected := "host.com"
   789  	authority := GetAuthority(uri)
   790  	actual := GetHost(authority)
   791  	if expected != actual {
   792  		t.Error(
   793  			"For", uri,
   794  			"expected", expected,
   795  			"got", actual,
   796  		)
   797  	}
   798  }
   799  
   800  func TestGetAuthorityNoUserinfoNoPortNoAbsolutePathWithQueryWithFragment(t *testing.T) {
   801  	uri := "scheme://host.com?query=something#fragment"
   802  	expected := "host.com"
   803  	actual := GetAuthority(uri)
   804  	if expected != actual {
   805  		t.Error(
   806  			"For", uri,
   807  			"expected", expected,
   808  			"got", actual,
   809  		)
   810  	}
   811  }
   812  
   813  func TestGetHostNoUserinfoNoPortNoAbsolutePathWithQueryWithFragment(t *testing.T) {
   814  	uri := "scheme://host.com?query=something#fragment"
   815  	expected := "host.com"
   816  	authority := GetAuthority(uri)
   817  	actual := GetHost(authority)
   818  	if expected != actual {
   819  		t.Error(
   820  			"For", uri,
   821  			"expected", expected,
   822  			"got", actual,
   823  		)
   824  	}
   825  }
   826  
   827  func TestGetAuthorityWithUserinfoNoPortNoAbsolutePathWithQueryWithFragment(t *testing.T) {
   828  	uri := "scheme://user@host.com?query=something#fragment"
   829  	expected := "user@host.com"
   830  	actual := GetAuthority(uri)
   831  	if expected != actual {
   832  		t.Error(
   833  			"For", uri,
   834  			"expected", expected,
   835  			"got", actual,
   836  		)
   837  	}
   838  }
   839  
   840  func TestGetHostWithUserinfoNoPortNoAbsolutePathWithQueryWithFragment(t *testing.T) {
   841  	uri := "scheme://user@host.com?query=something#fragment"
   842  	expected := "host.com"
   843  	authority := GetAuthority(uri)
   844  	actual := GetHost(authority)
   845  	if expected != actual {
   846  		t.Error(
   847  			"For", uri,
   848  			"expected", expected,
   849  			"got", actual,
   850  		)
   851  	}
   852  }
   853  
   854  func TestGetAuthorityNoUserinfoWithPortNoAbsolutePathWithQueryWithFragment(t *testing.T) {
   855  	uri := "scheme://host.com:123?query=something#fragment"
   856  	expected := "host.com:123"
   857  	actual := GetAuthority(uri)
   858  	if expected != actual {
   859  		t.Error(
   860  			"For", uri,
   861  			"expected", expected,
   862  			"got", actual,
   863  		)
   864  	}
   865  }
   866  
   867  func TestGetHostNoUserinfoWithPortNoAbsolutePathWithQueryWithFragment(t *testing.T) {
   868  	uri := "scheme://host.com:123?query=something#fragment"
   869  	expected := "host.com"
   870  	authority := GetAuthority(uri)
   871  	actual := GetHost(authority)
   872  	if expected != actual {
   873  		t.Error(
   874  			"For", uri,
   875  			"expected", expected,
   876  			"got", actual,
   877  		)
   878  	}
   879  }
   880  
   881  func TestGetAuthorityWithUserinfoWithPortNoAbsolutePathWithQueryWithFragment(t *testing.T) {
   882  	uri := "scheme://user@host.com:123?query=something#fragment"
   883  	expected := "user@host.com:123"
   884  	actual := GetAuthority(uri)
   885  	if expected != actual {
   886  		t.Error(
   887  			"For", uri,
   888  			"expected", expected,
   889  			"got", actual,
   890  		)
   891  	}
   892  }
   893  
   894  func TestGetHostWithUserinfoWithPortNoAbsolutePathWithQueryWithFragment(t *testing.T) {
   895  	uri := "scheme://user@host.com:123?query=something#fragment"
   896  	expected := "host.com"
   897  	authority := GetAuthority(uri)
   898  	actual := GetHost(authority)
   899  	if expected != actual {
   900  		t.Error(
   901  			"For", uri,
   902  			"expected", expected,
   903  			"got", actual,
   904  		)
   905  	}
   906  }
   907  
   908  func TestGetAuthorityNoUserinfoNoPortWithAbsolutePathWithQueryWithFragment(t *testing.T) {
   909  	uri := "scheme://host.com/path/to/something?query=something#fragment"
   910  	expected := "host.com"
   911  	actual := GetAuthority(uri)
   912  	if expected != actual {
   913  		t.Error(
   914  			"For", uri,
   915  			"expected", expected,
   916  			"got", actual,
   917  		)
   918  	}
   919  }
   920  
   921  func TestGetHostNoUserinfoNoPortWithAbsolutePathWithQueryWithFragment(t *testing.T) {
   922  	uri := "scheme://host.com/path/to/something?query=something#fragment"
   923  	expected := "host.com"
   924  	authority := GetAuthority(uri)
   925  	actual := GetHost(authority)
   926  	if expected != actual {
   927  		t.Error(
   928  			"For", uri,
   929  			"expected", expected,
   930  			"got", actual,
   931  		)
   932  	}
   933  }
   934  
   935  func TestGetAuthorityWithUserinfoNoPortWithAbsolutePathWithQueryWithFragment(t *testing.T) {
   936  	uri := "scheme://user@host.com/path/to/something?query=something#fragment"
   937  	expected := "user@host.com"
   938  	actual := GetAuthority(uri)
   939  	if expected != actual {
   940  		t.Error(
   941  			"For", uri,
   942  			"expected", expected,
   943  			"got", actual,
   944  		)
   945  	}
   946  }
   947  
   948  func TestGetHostWithUserinfoNoPortWithAbsolutePathWithQueryWithFragment(t *testing.T) {
   949  	uri := "scheme://user@host.com/path/to/something?query=something#fragment"
   950  	expected := "host.com"
   951  	authority := GetAuthority(uri)
   952  	actual := GetHost(authority)
   953  	if expected != actual {
   954  		t.Error(
   955  			"For", uri,
   956  			"expected", expected,
   957  			"got", actual,
   958  		)
   959  	}
   960  }
   961  
   962  func TestGetAuthorityNoUserinfoWithPortWithAbsolutePathWithQueryWithFragment(t *testing.T) {
   963  	uri := "scheme://host.com:123/path/to/something?query=something#fragment"
   964  	expected := "host.com:123"
   965  	actual := GetAuthority(uri)
   966  	if expected != actual {
   967  		t.Error(
   968  			"For", uri,
   969  			"expected", expected,
   970  			"got", actual,
   971  		)
   972  	}
   973  }
   974  
   975  func TestGetHostNoUserinfoWithPortWithAbsolutePathWithQueryWithFragment(t *testing.T) {
   976  	uri := "scheme://host.com:123/path/to/something?query=something#fragment"
   977  	expected := "host.com"
   978  	authority := GetAuthority(uri)
   979  	actual := GetHost(authority)
   980  	if expected != actual {
   981  		t.Error(
   982  			"For", uri,
   983  			"expected", expected,
   984  			"got", actual,
   985  		)
   986  	}
   987  }
   988  
   989  func TestGetAuthorityWithUserinfoWithPortWithAbsolutePathWithQueryWithFragment(t *testing.T) {
   990  	uri := "scheme://user@host.com:123/path/to/something?query=something#fragment"
   991  	expected := "user@host.com:123"
   992  	actual := GetAuthority(uri)
   993  	if expected != actual {
   994  		t.Error(
   995  			"For", uri,
   996  			"expected", expected,
   997  			"got", actual,
   998  		)
   999  	}
  1000  }
  1001  
  1002  func TestGetHostWithUserinfoWithPortWithAbsolutePathWithQueryWithFragment(t *testing.T) {
  1003  	uri := "scheme://user@host.com:123/path/to/something?query=something#fragment"
  1004  	expected := "host.com"
  1005  	authority := GetAuthority(uri)
  1006  	actual := GetHost(authority)
  1007  	if expected != actual {
  1008  		t.Error(
  1009  			"For", uri,
  1010  			"expected", expected,
  1011  			"got", actual,
  1012  		)
  1013  	}
  1014  }