// SPDX-FileCopyrightText: Copyright The Lima Authors1// SPDX-License-Identifier: Apache-2.023// From https://github.com/containerd/containerd/blob/v2.1.1/pkg/identifiers/validate_test.go4// SPDX-FileCopyrightText: Copyright The containerd Authors5// LICENSE: https://github.com/containerd/containerd/blob/v2.1.1/LICENSE6// NOTICE: https://github.com/containerd/containerd/blob/v2.1.1/NOTICE78/*9Copyright The containerd Authors.1011Licensed under the Apache License, Version 2.0 (the "License");12you may not use this file except in compliance with the License.13You may obtain a copy of the License at1415http://www.apache.org/licenses/LICENSE-2.01617Unless required by applicable law or agreed to in writing, software18distributed under the License is distributed on an "AS IS" BASIS,19WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.20See the License for the specific language governing permissions and21limitations under the License.22*/2324package identifiers2526import (27"strings"28"testing"2930"gotest.tools/v3/assert"31)3233func TestValidIdentifiers(t *testing.T) {34for _, input := range []string{35"default",36"Default",37t.Name(),38"default-default",39"containerd.io",40"foo.boo",41"swarmkit.docker.io",42"0912341234",43"task.0.0123456789",44"container.system-75-f19a.00",45"underscores_are_allowed",46strings.Repeat("a", maxLength),47} {48t.Run(input, func(t *testing.T) {49assert.NilError(t, Validate(input))50})51}52}5354func TestInvalidIdentifiers(t *testing.T) {55for _, input := range []string{56"",57".foo..foo",58"foo/foo",59"foo/..",60"foo..foo",61"foo.-boo",62"-foo.boo",63"foo.boo-",64"but__only_tasteful_underscores",65"zn--e9.org", // or something like it!66"default--default",67strings.Repeat("a", maxLength+1),68} {69t.Run(input, func(t *testing.T) {70assert.ErrorContains(t, Validate(input), "")71})72}73}747576