osbuild2: add support for org.osbuild.authselect stage
Add support for the `org.osbuild.authselect` osbuild stage [1], which allows one to set system identity profile and authentication sources using `authselect`. Add unit test cases for the newly added stage. [1] https://github.com/osbuild/osbuild/pull/696 Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
006ff98025
commit
34d52aa8e1
4 changed files with 58 additions and 0 deletions
15
internal/osbuild2/authselect_stage.go
Normal file
15
internal/osbuild2/authselect_stage.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package osbuild2
|
||||
|
||||
type AuthselectStageOptions struct {
|
||||
Profile string `json:"profile_id"`
|
||||
Features []string `json:"features,omitempty"`
|
||||
}
|
||||
|
||||
func (AuthselectStageOptions) isStageOptions() {}
|
||||
|
||||
func NewAuthselectStage(options *AuthselectStageOptions) *Stage {
|
||||
return &Stage{
|
||||
Type: "org.osbuild.authselect",
|
||||
Options: options,
|
||||
}
|
||||
}
|
||||
16
internal/osbuild2/authselect_stage_test.go
Normal file
16
internal/osbuild2/authselect_stage_test.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package osbuild2
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNewAuthselectStage(t *testing.T) {
|
||||
expectedStage := &Stage{
|
||||
Type: "org.osbuild.authselect",
|
||||
Options: &AuthselectStageOptions{},
|
||||
}
|
||||
actualStage := NewAuthselectStage(&AuthselectStageOptions{})
|
||||
assert.Equal(t, expectedStage, actualStage)
|
||||
}
|
||||
|
|
@ -67,6 +67,8 @@ func (stage *Stage) UnmarshalJSON(data []byte) error {
|
|||
var options StageOptions
|
||||
var inputs Inputs
|
||||
switch rawStage.Type {
|
||||
case "org.osbuild.authselect":
|
||||
options = new(AuthselectStageOptions)
|
||||
case "org.osbuild.fix-bls":
|
||||
options = new(FixBLSStageOptions)
|
||||
case "org.osbuild.fstab":
|
||||
|
|
|
|||
|
|
@ -53,6 +53,31 @@ func TestStage_UnmarshalJSON(t *testing.T) {
|
|||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "authselect",
|
||||
fields: fields{
|
||||
Type: "org.osbuild.authselect",
|
||||
Options: &AuthselectStageOptions{
|
||||
Profile: "sssd",
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
data: []byte(`{"type":"org.osbuild.authselect","options":{"profile_id":"sssd"}}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "authselect-features",
|
||||
fields: fields{
|
||||
Type: "org.osbuild.authselect",
|
||||
Options: &AuthselectStageOptions{
|
||||
Profile: "nis",
|
||||
Features: []string{"with-ecryptfs", "with-mkhomedir"},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
data: []byte(`{"type":"org.osbuild.authselect","options":{"profile_id":"nis","features":["with-ecryptfs","with-mkhomedir"]}}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "cloud-init",
|
||||
fields: fields{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue