()
| 52 | } |
| 53 | |
| 54 | func (s *containerTestSuite) TestContainer_ProfilesMulti() { |
| 55 | // Create an unprivileged profile |
| 56 | err := s.d.db.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error { |
| 57 | profile := cluster.Profile{ |
| 58 | Name: "unprivileged", |
| 59 | Description: "unprivileged", |
| 60 | Project: "default", |
| 61 | } |
| 62 | |
| 63 | id, err := cluster.CreateProfile(ctx, tx.Tx(), profile) |
| 64 | if err != nil { |
| 65 | return err |
| 66 | } |
| 67 | |
| 68 | err = cluster.CreateProfileConfig(ctx, tx.Tx(), id, map[string]string{"security.privileged": "true"}) |
| 69 | if err != nil { |
| 70 | return err |
| 71 | } |
| 72 | |
| 73 | return err |
| 74 | }) |
| 75 | |
| 76 | s.Req.Nil(err, "Failed to create the unprivileged profile.") |
| 77 | defer func() { |
| 78 | _ = s.d.db.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error { |
| 79 | return cluster.DeleteProfile(ctx, tx.Tx(), "default", "unprivileged") |
| 80 | }) |
| 81 | }() |
| 82 | |
| 83 | var testProfiles []api.Profile |
| 84 | |
| 85 | err = s.d.db.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error { |
| 86 | testProfiles, err = tx.GetProfiles(ctx, "default", []string{"default", "unprivileged"}) |
| 87 | |
| 88 | return err |
| 89 | }) |
| 90 | s.Req.Nil(err) |
| 91 | |
| 92 | args := db.InstanceArgs{ |
| 93 | Type: instancetype.Container, |
| 94 | Ephemeral: false, |
| 95 | Profiles: testProfiles, |
| 96 | Name: "testFoo", |
| 97 | } |
| 98 | |
| 99 | c, op, _, err := instance.CreateInternal(s.d.State(), args, nil, true, true, false) |
| 100 | s.Req.Nil(err) |
| 101 | op.Done(nil) |
| 102 | defer func() { _ = c.Delete(true, true) }() |
| 103 | |
| 104 | profiles := c.Profiles() |
| 105 | s.Len( |
| 106 | profiles, |
| 107 | 2, |
| 108 | "Didn't get both profiles in instanceCreateInternal.", |
| 109 | ) |
| 110 | |
| 111 | s.True( |
nothing calls this directly
no test coverage detected