go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/network/resources/domain/name_test.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package domain
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  	"github.com/stretchr/testify/require"
    11  )
    12  
    13  func TestDomainName(t *testing.T) {
    14  	tests := map[string]Name{
    15  		"https://google.com": {
    16  			Host:                "google.com",
    17  			EffectiveTLDPlusOne: "google.com",
    18  			TLD:                 "com",
    19  			IcannManagedTLD:     true,
    20  			Labels:              []string{"google", "com"},
    21  		},
    22  		"https://mail.google.com": {
    23  			Host:                "mail.google.com",
    24  			EffectiveTLDPlusOne: "google.com",
    25  			TLD:                 "com",
    26  			IcannManagedTLD:     true,
    27  			Labels:              []string{"mail", "google", "com"},
    28  		},
    29  		"https://blog.google": {
    30  			Host:                "blog.google",
    31  			EffectiveTLDPlusOne: "blog.google",
    32  			TLD:                 "google",
    33  			IcannManagedTLD:     true,
    34  			Labels:              []string{"blog", "google"},
    35  		},
    36  		"https://hello.example": {
    37  			Host:                "hello.example",
    38  			EffectiveTLDPlusOne: "hello.example",
    39  			TLD:                 "example",
    40  			IcannManagedTLD:     false,
    41  			Labels:              []string{"hello", "example"},
    42  		},
    43  		"https://hello.notpublicsuffix": {
    44  			Host:                "hello.notpublicsuffix",
    45  			EffectiveTLDPlusOne: "hello.notpublicsuffix",
    46  			TLD:                 "notpublicsuffix",
    47  			IcannManagedTLD:     false,
    48  			Labels:              []string{"hello", "notpublicsuffix"},
    49  		},
    50  		"https://mondoo.com": {
    51  			Host:                "mondoo.com",
    52  			EffectiveTLDPlusOne: "mondoo.com",
    53  			TLD:                 "com",
    54  			IcannManagedTLD:     true,
    55  			Labels:              []string{"mondoo", "com"},
    56  		},
    57  		"mondoo.com": {
    58  			Host:                "mondoo.com",
    59  			EffectiveTLDPlusOne: "mondoo.com",
    60  			TLD:                 "com",
    61  			IcannManagedTLD:     true,
    62  			Labels:              []string{"mondoo", "com"},
    63  		},
    64  	}
    65  	for k, expected := range tests {
    66  		dn, err := Parse(k)
    67  		require.NoError(t, err)
    68  		assert.Equal(t, expected, dn, k)
    69  	}
    70  }