// TestInstanceUserInfo tests that the user info is set properly
// as the user changes for different modifications of the instance.
TestInstanceUserInfo tests that the user info is set properly
as the user changes for different modifications of the instance.
// TestInstanceUserInfo tests that the user info is set properly // as the user changes for different modifications of the instance .
func TestInstanceUserInfo(t *testing.T) {
	prevOrigIDEnablement := sctestutil.EnableOriginatingIdentity(t, true)
	defer utilfeature.DefaultFeatureGate.Set(fmt.Sprintf("%v=%v", scfeatures.OriginatingIdentity, prevOrigIDEnablement))
	creatorUserName := "creator"
	createdInstance := getTestInstance()
	createContext := sctestutil.ContextWithUserName(creatorUserName)
	instanceRESTStrategies.PrepareForCreate(createContext, createdInstance)
	if e, a := creatorUserName, createdInstance.Spec.UserInfo.Username; e != a {
		t.Errorf("unexpected user info in created spec: expected %v, got %v", e, a)
	}
	updaterUserName := "updater"
	updatedInstance := getTestInstance()
	updatedInstance.Spec.UpdateRequests = updatedInstance.Spec.UpdateRequests + 1
	updateContext := sctestutil.ContextWithUserName(updaterUserName)
	instanceRESTStrategies.PrepareForUpdate(updateContext, updatedInstance, createdInstance)
	if e, a := updaterUserName, updatedInstance.Spec.UserInfo.Username; e != a {
		t.Errorf("unexpected user info in updated spec: expected %v, got %v", e, a)
	}
	deleterUserName := "deleter"
	deletedInstance := getTestInstance()
	deleteContext := sctestutil.ContextWithUserName(deleterUserName)
	instanceRESTStrategies.CheckGracefulDelete(deleteContext, deletedInstance, nil)
	if e, a := deleterUserName, deletedInstance.Spec.UserInfo.Username; e != a {
		t.Errorf("unexpected user info in deleted spec: expected %v, got %v", e, a)
	}
}
func TestInstanceUserInfo ( t * testing . T ) { prevOrigIDEnablement := sctestutil . EnableOriginatingIdentity ( t , true ) defer utilfeature . DefaultFeatureGate . Set ( fmt . Sprintf ( " " , scfeatures . OriginatingIdentity , prevOrigIDEnablement ) ) creatorUserName := " " createdInstance := getTestInstance ( ) createContext := sctestutil . ContextWithUserName ( creatorUserName ) instanceRESTStrategies . PrepareForCreate ( createContext , createdInstance ) if e , a := creatorUserName , createdInstance . Spec . UserInfo . Username ; e != a { t . Errorf ( " " , e , a ) } updaterUserName := " " updatedInstance := getTestInstance ( ) updatedInstance . Spec . UpdateRequests = updatedInstance . Spec . UpdateRequests + 1 updateContext := sctestutil . ContextWithUserName ( updaterUserName ) instanceRESTStrategies . PrepareForUpdate ( updateContext , updatedInstance , createdInstance ) if e , a := updaterUserName , updatedInstance . Spec . UserInfo . Username ; e != a { t . Errorf ( " " , e , a ) } deleterUserName := " " deletedInstance := getTestInstance ( ) deleteContext := sctestutil . ContextWithUserName ( deleterUserName ) instanceRESTStrategies . CheckGracefulDelete ( deleteContext , deletedInstance , nil ) if e , a := deleterUserName , deletedInstance . Spec . UserInfo . Username ; e != a { t . Errorf ( " " , e , a ) } }
TestInstanceUserInfo tests that the user info is set properly
as the user changes for different modifications of the instance.
TestInstanceUserInfo tests that the user info is set properly as the user changes for different modifications of the instance .
// Enable the OriginatingIdentity feature