testresources

package
v0.0.0-...-1d673d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Trace1 = func() *apiv2.AuditTrace {
		return &apiv2.AuditTrace{
			Uuid:      "d1ff7267-2fbb-4a63-a7c1-44f1a83381a7",
			Timestamp: timestamppb.New(e2e.TimeBubbleStartTime()),
			User:      "me",
			Tenant:    "a",
			Project:   new(Project1().Uuid),
			Method:    "/apiv2.Create/",
			Body:      new("request body"),
			SourceIp:  "1.2.3.4",
			Phase:     apiv2.AuditPhase_AUDIT_PHASE_REQUEST,
		}
	}

	Trace2 = func() *apiv2.AuditTrace {
		return &apiv2.AuditTrace{
			Uuid:       "d1ff7267-2fbb-4a63-a7c1-44f1a83381a7",
			Timestamp:  timestamppb.New(e2e.TimeBubbleStartTime()),
			User:       "me",
			Tenant:     "a",
			Project:    new(Project1().Uuid),
			Method:     "/apiv2.List/",
			Body:       new("result body"),
			SourceIp:   "1.2.3.4",
			ResultCode: new(int32(codes.AlreadyExists)),
			Phase:      apiv2.AuditPhase_AUDIT_PHASE_RESPONSE,
		}
	}

	Trace3 = func() *apiv2.AuditTrace {
		return &apiv2.AuditTrace{
			Uuid:      "5091c4e9-e8db-483c-ab6b-fe14f82570a7",
			Timestamp: timestamppb.New(e2e.TimeBubbleStartTime().AddDate(1, 0, 0)),
			User:      "Larry",
			Tenant:    "b",
			Project:   new(Project1().Uuid),
			Method:    "/apiv2.List/",
			Body:      new("result body"),
			SourceIp:  "1.2.3.4",
			Phase:     apiv2.AuditPhase_AUDIT_PHASE_REQUEST,
		}
	}
)
View Source
var (
	Component1 = func() *apiv2.Component {
		return &apiv2.Component{
			Uuid:       "c1a2b3d4-e5f6-7890-abcd-ef1234567890",
			Type:       apiv2.ComponentType_COMPONENT_TYPE_METAL_CORE,
			Identifier: "metal-core-1",
			StartedAt:  timestamppb.New(e2e.TimeBubbleStartTime()),
			ReportedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			Interval:   durationpb.New(10 * time.Second),
			Version: &apiv2.Version{
				Version: "v1.0.0",
			},
			Token: &apiv2.Token{
				Uuid:    "t1a2b3d4-e5f6-7890-abcd-ef1234567890",
				Expires: timestamppb.New(e2e.TimeBubbleStartTime().Add(24 * time.Hour)),
			},
		}
	}
	Component2 = func() *apiv2.Component {
		return &apiv2.Component{
			Uuid:       "d2b3c4e5-f6a7-8901-bcde-f12345678901",
			Type:       apiv2.ComponentType_COMPONENT_TYPE_PIXIECORE,
			Identifier: "pixiecore-1",
			StartedAt:  timestamppb.New(e2e.TimeBubbleStartTime()),
			ReportedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			Interval:   durationpb.New(10 * time.Second),
			Version: &apiv2.Version{
				Version: "v2.0.0",
			},
			Token: &apiv2.Token{
				Uuid:    "t2b3c4e5-f6a7-8901-bcde-f12345678901",
				Expires: timestamppb.New(e2e.TimeBubbleStartTime().Add(48 * time.Hour)),
			},
		}
	}
)
View Source
var (
	Image1 = func() *apiv2.Image {
		return &apiv2.Image{
			Id:             "ubuntu-24.04",
			Name:           new("Ubuntu 24.04"),
			Description:    new("Ubuntu 24.04 LTS"),
			Features:       []apiv2.ImageFeature{apiv2.ImageFeature_IMAGE_FEATURE_MACHINE},
			Classification: apiv2.ImageClassification_IMAGE_CLASSIFICATION_SUPPORTED,
			Meta:           &apiv2.Meta{},
		}
	}
	Image2 = func() *apiv2.Image {
		return &apiv2.Image{
			Id:             "firewall-3.0",
			Name:           new("Firewall 3.0"),
			Description:    new("Metal Firewall"),
			Features:       []apiv2.ImageFeature{apiv2.ImageFeature_IMAGE_FEATURE_FIREWALL},
			Classification: apiv2.ImageClassification_IMAGE_CLASSIFICATION_PREVIEW,
			Meta:           &apiv2.Meta{},
		}
	}
)
View Source
var (
	IP1 = func() *apiv2.IP {
		return &apiv2.IP{
			Uuid:        "2e0144a2-09ef-42b7-b629-4263295db6e8",
			Network:     "internet",
			Ip:          "1.1.1.1",
			Name:        "a",
			Description: "a description",
			Project:     "ce19a655-7933-4745-8f3e-9592b4a90488",
			Type:        apiv2.IPType_IP_TYPE_STATIC,
			Meta: &apiv2.Meta{
				Labels: &apiv2.Labels{
					Labels: map[string]string{
						tag.ClusterServiceFQN: "<cluster>/default/ingress-nginx",
					},
				},
			},
		}
	}
	IP2 = func() *apiv2.IP {
		return &apiv2.IP{
			Uuid:        "9cef40ec-29c6-4dfa-aee8-47ee1f49223d",
			Network:     "internet",
			Ip:          "4.3.2.1",
			Name:        "b",
			Description: "b description",
			Project:     "46bdfc45-9c8d-4268-b359-b40e3079d384",
			Type:        apiv2.IPType_IP_TYPE_EPHEMERAL,
			Meta: &apiv2.Meta{
				Labels: &apiv2.Labels{
					Labels: map[string]string{
						"a": "b",
					},
				},
			},
		}
	}
)
View Source
var (
	Project1 = func() *apiv2.Project {
		return &apiv2.Project{
			Uuid:        "0d81bca7-73f6-4da3-8397-4a8c52a0c583",
			Name:        "project-a",
			Description: "first project",
			Tenant:      "metal-stack",
			Meta: &apiv2.Meta{
				CreatedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			},
		}
	}
	Project2 = func() *apiv2.Project {
		return &apiv2.Project{
			Uuid:        "f3b4e6a1-2c8d-4e5f-a7b9-1d3e5f7a9b0c",
			Name:        "project-b",
			Description: "second project",
			Tenant:      "metal-stack",
			Meta: &apiv2.Meta{
				CreatedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			},
		}
	}

	Project1Invite = func() *apiv2.ProjectInvite {
		return &apiv2.ProjectInvite{
			Secret:      "secret",
			Project:     "0d81bca7-73f6-4da3-8397-4a8c52a0c583",
			Role:        apiv2.ProjectRole_PROJECT_ROLE_EDITOR,
			Joined:      false,
			ProjectName: "project-a",
			TenantName:  "metal-stack",
			ExpiresAt:   timestamppb.New(e2e.TimeBubbleStartTime().Add(48 * time.Hour)),
		}
	}
	Project2Invite = func() *apiv2.ProjectInvite {
		return &apiv2.ProjectInvite{
			Secret:      "secret",
			Project:     "f3b4e6a1-2c8d-4e5f-a7b9-1d3e5f7a9b0c",
			Role:        apiv2.ProjectRole_PROJECT_ROLE_EDITOR,
			Joined:      false,
			ProjectName: "project-b",
			TenantName:  "metal-stack",
			ExpiresAt:   timestamppb.New(e2e.TimeBubbleStartTime().Add(48 * time.Hour)),
		}
	}

	Project1Members = func() *apiv2.ProjectMember {
		return &apiv2.ProjectMember{
			Id:                  "16d6e8ba-f574-494f-8d5e-74f6cb2d8db0",
			Role:                apiv2.ProjectRole_PROJECT_ROLE_OWNER,
			InheritedMembership: false,
			CreatedAt:           timestamppb.New(e2e.TimeBubbleStartTime()),
		}
	}
	Project2Members = func() *apiv2.ProjectMember {
		return &apiv2.ProjectMember{
			Id:                  "40c0da4b-9eb9-4371-91aa-1ae62193fa54",
			Role:                apiv2.ProjectRole_PROJECT_ROLE_EDITOR,
			InheritedMembership: true,
			CreatedAt:           timestamppb.New(e2e.TimeBubbleStartTime()),
		}
	}
)
View Source
var (
	Switch1 = func() *apiv2.Switch {
		return &apiv2.Switch{
			Id:             "leaf01",
			Partition:      "fra-equ01",
			Rack:           new("rack-1"),
			Description:    "leaf switch 1",
			ManagementIp:   "10.0.0.1",
			ManagementUser: new("admin"),
			MachineConnections: []*apiv2.MachineConnection{
				&apiv2.MachineConnection{
					MachineId: "id1",
					Nic:       Nic1(),
				},
			},
			Nics: []*apiv2.SwitchNic{Nic1(), Nic2()},
			Os: &apiv2.SwitchOS{
				Vendor:           apiv2.SwitchOSVendor_SWITCH_OS_VENDOR_SONIC,
				Version:          "4.2.0",
				MetalCoreVersion: "v0.9.1 (abc1234), tags/v0.9.1",
			},
			LastSync: &apiv2.SwitchSync{
				Time:     timestamppb.New(e2e.TimeBubbleStartTime()),
				Duration: durationpb.New(100 * time.Millisecond),
			},
			Meta: &apiv2.Meta{
				CreatedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			},
		}
	}
	Switch2 = func() *apiv2.Switch {
		return &apiv2.Switch{
			Id:             "leaf02",
			Partition:      "fra-equ01",
			Rack:           new("rack-1"),
			Description:    "leaf switch 2",
			ManagementIp:   "10.0.0.2",
			ManagementUser: new("admin"),
			Os: &apiv2.SwitchOS{
				Vendor:           apiv2.SwitchOSVendor_SWITCH_OS_VENDOR_SONIC,
				Version:          "4.2.0",
				MetalCoreVersion: "v0.9.1 (abc1234), tags/v0.9.1",
			},
			LastSync: &apiv2.SwitchSync{
				Time:     timestamppb.New(e2e.TimeBubbleStartTime()),
				Duration: durationpb.New(200 * time.Millisecond),
			},
			Meta: &apiv2.Meta{
				CreatedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			},
		}
	}

	Nic1 = func() *apiv2.SwitchNic {
		return &apiv2.SwitchNic{
			Name:       "Ethernet0",
			Identifier: "oid:0x1000000000001",
			Mac:        "52:54:00:ab:cd:01",
			Vrf:        new("default"),
			State: &apiv2.NicState{
				Desired: new(apiv2.SwitchPortStatus_SWITCH_PORT_STATUS_UP),
				Actual:  apiv2.SwitchPortStatus_SWITCH_PORT_STATUS_UP,
			},
			BgpFilter: &apiv2.BGPFilter{
				Cidrs: []string{
					"10.0.0.0/24",
					"192.168.100.0/24",
				},
				Vnis: []string{
					"10001",
					"10002",
				},
			},
			BgpPortState: &apiv2.SwitchBGPPortState{
				Neighbor:              "10.0.0.2",
				PeerGroup:             "TOR-LEAFS",
				VrfName:               "default",
				BgpState:              apiv2.BGPState_BGP_STATE_ESTABLISHED,
				BgpTimerUpEstablished: timestamppb.New(time.Now().Add(-2 * time.Hour)),
				SentPrefixCounter:     120,
				AcceptedPrefixCounter: 118,
			},
		}
	}
	Nic2 = func() *apiv2.SwitchNic {
		return &apiv2.SwitchNic{
			Name:       "Ethernet4",
			Identifier: "oid:0x1000000000002",
			Mac:        "52:54:00:ab:cd:02",
			State: &apiv2.NicState{
				Desired: new(apiv2.SwitchPortStatus_SWITCH_PORT_STATUS_UP),
				Actual:  apiv2.SwitchPortStatus_SWITCH_PORT_STATUS_DOWN,
			},
			BgpFilter: &apiv2.BGPFilter{
				Cidrs: []string{"10.1.0.0/24"},
				Vnis:  []string{"20001"},
			},
			BgpPortState: &apiv2.SwitchBGPPortState{
				Neighbor:              "10.1.0.2",
				PeerGroup:             "TOR-LEAFS",
				VrfName:               "default",
				BgpState:              apiv2.BGPState_BGP_STATE_IDLE,
				BgpTimerUpEstablished: nil,
				SentPrefixCounter:     0,
				AcceptedPrefixCounter: 0,
			},
		}
	}
	SwitchWithMachines1 = func() *apiv2.SwitchWithMachines {
		return &apiv2.SwitchWithMachines{
			Id:        Switch1().Id,
			Partition: Switch1().Partition,
			Rack:      *Switch1().Rack,
			Connections: []*apiv2.SwitchNicWithMachine{
				{
					Nic: Switch1().Nics[0],
					Machine: &apiv2.Machine{
						Uuid: "id1",
						Partition: &apiv2.Partition{
							Id: Switch1().Partition,
						},
						Rack: *Switch1().Rack,
						Size: &apiv2.Size{
							Id: "m1-small",
						},
					},
					Fru: &apiv2.MachineFRU{
						ProductSerial:     new("ps-1"),
						ChassisPartSerial: new("cs-1"),
					},
				},
			},
		}
	}
)
View Source
var (
	Task1 = func() *adminv2.TaskInfo {
		return &adminv2.TaskInfo{
			Id:            "00dc6a98-bd80-787a-9725-ffb692d83261",
			Queue:         "default",
			Type:          "image-provision",
			Payload:       []byte(`{"machine_id":"machine1"}`),
			State:         adminv2.TaskState_TASK_STATE_ACTIVE,
			MaxRetry:      3,
			Retried:       1,
			LastError:     "connection timeout",
			LastFailedAt:  timestamppb.New(e2e.TimeBubbleStartTime().Add(-5 * time.Minute)),
			Timeout:       durationpb.New(30 * time.Second),
			Deadline:      timestamppb.New(e2e.TimeBubbleStartTime().Add(5 * time.Minute)),
			NextProcessAt: timestamppb.New(e2e.TimeBubbleStartTime().Add(10 * time.Second)),
			Retention:     durationpb.New(24 * time.Hour),
			CompletedAt:   nil,
		}
	}
	Task2 = func() *adminv2.TaskInfo {
		return &adminv2.TaskInfo{
			Id:            "00dc6ab4-34c0-73ce-af77-3e07748d0e0d",
			Queue:         "default",
			Type:          "firewall-update",
			Payload:       []byte(`{"firewall_id":"fw1"}`),
			State:         adminv2.TaskState_TASK_STATE_PENDING,
			MaxRetry:      5,
			Retried:       0,
			LastError:     "",
			LastFailedAt:  nil,
			Timeout:       durationpb.New(60 * time.Second),
			Deadline:      timestamppb.New(e2e.TimeBubbleStartTime().Add(10 * time.Minute)),
			NextProcessAt: timestamppb.New(e2e.TimeBubbleStartTime().Add(2 * time.Second)),
			Retention:     durationpb.New(48 * time.Hour),
			CompletedAt:   nil,
		}
	}
	Task3 = func() *adminv2.TaskInfo {
		return &adminv2.TaskInfo{
			Id:            "00dc6ab5-1f20-7426-a397-8644fb78324e",
			Queue:         "high-priority",
			Type:          "machine-reimage",
			Payload:       []byte(`{"machine_id":"machine2"}`),
			State:         adminv2.TaskState_TASK_STATE_COMPLETED,
			MaxRetry:      3,
			Retried:       0,
			LastError:     "",
			LastFailedAt:  nil,
			Timeout:       durationpb.New(5 * time.Minute),
			Deadline:      timestamppb.New(e2e.TimeBubbleStartTime().Add(30 * time.Minute)),
			NextProcessAt: nil,
			Retention:     durationpb.New(7 * 24 * time.Hour),
			CompletedAt:   timestamppb.New(e2e.TimeBubbleStartTime().Add(-10 * time.Minute)),
			Result:        []byte(`success`),
		}
	}
)
View Source
var (
	Tenant1 = func() *apiv2.Tenant {
		return &apiv2.Tenant{
			Login:       "metal-stack",
			Name:        "Metal Stack",
			Email:       "info@metal-stack.io",
			Description: "a tenant",
			Meta: &apiv2.Meta{
				CreatedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			},
		}
	}
	Tenant2 = func() *apiv2.Tenant {
		return &apiv2.Tenant{
			Login:       "acme-corp",
			Name:        "ACME Corp",
			Email:       "admin@acme.io",
			Description: "another tenant",
			Meta: &apiv2.Meta{
				CreatedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			},
		}
	}

	Tenant1Invite = func() *apiv2.TenantInvite {
		return &apiv2.TenantInvite{
			Secret:           "secret",
			TargetTenant:     "metal-stack",
			TargetTenantName: "Metal Stack",
			Role:             apiv2.TenantRole_TENANT_ROLE_VIEWER,
			Joined:           false,
			Tenant:           "metal-stack",
			TenantName:       "Metal Stack",
			ExpiresAt:        timestamppb.New(e2e.TimeBubbleStartTime().Add(48 * time.Hour)),
		}
	}
	Tenant2Invite = func() *apiv2.TenantInvite {
		return &apiv2.TenantInvite{
			Secret:           "secret",
			TargetTenant:     "acme-corp",
			TargetTenantName: "ACME Corp",
			Role:             apiv2.TenantRole_TENANT_ROLE_EDITOR,
			Joined:           false,
			Tenant:           "acme-corp",
			TenantName:       "ACME Corp",
			ExpiresAt:        timestamppb.New(e2e.TimeBubbleStartTime().Add(48 * time.Hour)),
		}
	}

	Tenant1Members = func() *apiv2.TenantMember {
		return &apiv2.TenantMember{
			Id:        "16d6e8ba-f574-494f-8d5e-74f6cb2d8db0",
			Role:      apiv2.TenantRole_TENANT_ROLE_OWNER,
			CreatedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			Projects:  []string{Project1().Uuid, Project2().Uuid},
		}
	}
	Tenant2Members = func() *apiv2.TenantMember {
		return &apiv2.TenantMember{
			Id:        "40c0da4b-9eb9-4371-91aa-1ae62193fa54",
			Role:      apiv2.TenantRole_TENANT_ROLE_EDITOR,
			CreatedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			Projects:  []string{Project1().Uuid},
		}
	}
)
View Source
var (
	Token1 = func() *apiv2.Token {
		return &apiv2.Token{
			Uuid:        "a3b1f6d2-4e8c-4f7a-9d2e-1b5c8f3a7e90",
			User:        "admin@metal-stack.io",
			Description: "ci token",
			TokenType:   apiv2.TokenType_TOKEN_TYPE_API,
			Expires:     timestamppb.New(e2e.TimeBubbleStartTime().Add(24 * time.Hour)),
			IssuedAt:    timestamppb.New(e2e.TimeBubbleStartTime()),
			Permissions: nil,
			Meta: &apiv2.Meta{
				CreatedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			},
		}
	}
	Token2 = func() *apiv2.Token {
		return &apiv2.Token{
			Uuid:        "b4c2e7f3-5a9d-4b8e-a1c3-2d6f9e4b8a01",
			User:        "dev@metal-stack.io",
			Description: "dev token",
			TokenType:   apiv2.TokenType_TOKEN_TYPE_API,
			Expires:     timestamppb.New(e2e.TimeBubbleStartTime().Add(48 * time.Hour)),
			IssuedAt:    timestamppb.New(e2e.TimeBubbleStartTime()),
			Permissions: []*apiv2.MethodPermission{
				&apiv2.MethodPermission{
					Subject: Project1().Uuid,
					Methods: []string{"api/method1", "api/method2"},
				},
				&apiv2.MethodPermission{
					Subject: Tenant1().Login,
					Methods: []string{"api/method3"},
				},
			},
			Meta: &apiv2.Meta{
				CreatedAt: timestamppb.New(e2e.TimeBubbleStartTime()),
			},
		}
	}
)
View Source
var (
	User = func() *apiv2.User {
		return &apiv2.User{
			Name:          "Larry",
			Email:         "larry@metal-stack.io",
			Login:         "larry@metal-stack.io@openid-connect",
			AvatarUrl:     "",
			DefaultTenant: Tenant1(),
			Tenants:       []*apiv2.Tenant{Tenant1(), Tenant2()},
			Projects:      []*apiv2.Project{Project1(), Project2()},
		}
	}
)
View Source
var (
	Version = func() *apiv2.Version {
		return &apiv2.Version{
			Version:   "v0.1.8",
			Revision:  "tags/v0.1.8-0-g476edc0",
			GitSha1:   "477edc0b",
			BuildDate: "2026-03-21T15:35:07+00:00",
		}
	}
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL