@@ -214,6 +214,7 @@ func (s *apiBaseSuite) SetUpTest(c *check.C) {
s.storeSigning = assertstest.NewStoreStack (" can0nical" , rootPrivKey, storePrivKey)
s.trustedRestorer = sysdb.InjectTrusted (s.storeSigning .Trusted )
+ assertstateAutoRefreshAssertions = nil
assertstateRefreshSnapDeclarations = nil
snapstateCoreInfo = nil
snapstateInstall = nil
@@ -236,6 +237,7 @@ func (s *apiBaseSuite) TearDownTest(c *check.C) {
ensureStateSoon = ensureStateSoonImpl
dirs.SetRootDir (" " )
+ assertstateAutoRefreshAssertions = assertstate.AutoRefreshAssertions
assertstateRefreshSnapDeclarations = assertstate.RefreshSnapDeclarations
snapstateCoreInfo = snapstate.CoreInfo
snapstateInstall = snapstate.Install
@@ -615,6 +617,7 @@ func (s *apiSuite) TestListIncludesAll(c *check.C) {
" snapstateRevert" ,
" snapstateRevertToRevision" ,
" assertstateRefreshSnapDeclarations" ,
+ " assertstateAutoRefreshAssertions" ,
" unsafeReadSnapInfo" ,
" osutilAddUser" ,
" setupLocalUser" ,
@@ -2846,7 +2849,7 @@ func (s *apiSuite) TestRefreshIgnoreValidation(c *check.C) {
}
func (s *apiSuite ) TestPostSnapsOp (c *check .C ) {
- assertstateRefreshSnapDeclarations = func (*state.State , int ) error { return nil }
+ assertstateAutoRefreshAssertions = func (*state.State , int ) error { return nil }
snapstateUpdateMany = func (s *state.State , names []string , userID int ) ([]string , []*state.TaskSet , error ) {
c.Check (names, check.HasLen , 0 )
t := s.NewTask (" fake-refresh-all" , " Refreshing everything" )
@@ -2877,10 +2880,10 @@ func (s *apiSuite) TestPostSnapsOp(c *check.C) {
}
func (s *apiSuite ) TestRefreshAll (c *check .C ) {
- refreshSnapDecls := false
- assertstateRefreshSnapDeclarations = func (s *state.State , userID int ) error {
- refreshSnapDecls = true
- return assertstate.RefreshSnapDeclarations (s , userID)
+ autoRefreshAssertions := false
+ assertstateAutoRefreshAssertions = func (st *state.State , userID int ) error {
+ autoRefreshAssertions = true
+ return assertstate.AutoRefreshAssertions (st , userID)
}
d := s.daemon (c)
@@ -2892,7 +2895,7 @@ func (s *apiSuite) TestRefreshAll(c *check.C) {
{[]string {" fake" }, ` Refresh snap "fake"` },
{[]string {" fake1" , " fake2" }, ` Refresh snaps "fake1", "fake2"` },
} {
- refreshSnapDecls = false
+ autoRefreshAssertions = false
snapstateUpdateMany = func (s *state.State , names []string , userID int ) ([]string , []*state.TaskSet , error ) {
c.Check (names, check.HasLen , 0 )
@@ -2907,15 +2910,15 @@ func (s *apiSuite) TestRefreshAll(c *check.C) {
st.Unlock ()
c.Assert (err, check.IsNil )
c.Check (summary, check.Equals , tst.msg )
- c.Check (refreshSnapDecls , check.Equals , true )
+ c.Check (autoRefreshAssertions , check.Equals , true )
}
}
func (s *apiSuite ) TestRefreshAllNoChanges (c *check .C ) {
- refreshSnapDecls := false
- assertstateRefreshSnapDeclarations = func (s *state.State , userID int ) error {
- refreshSnapDecls = true
- return assertstate.RefreshSnapDeclarations (s , userID)
+ autoRefreshAssertions := false
+ assertstateAutoRefreshAssertions = func (st *state.State , userID int ) error {
+ autoRefreshAssertions = true
+ return assertstate.AutoRefreshAssertions (st , userID)
}
snapstateUpdateMany = func (s *state.State , names []string , userID int ) ([]string , []*state.TaskSet , error ) {
@@ -2931,14 +2934,14 @@ func (s *apiSuite) TestRefreshAllNoChanges(c *check.C) {
st.Unlock ()
c.Assert (err, check.IsNil )
c.Check (summary, check.Equals , ` Refresh all snaps: no updates` )
- c.Check (refreshSnapDecls , check.Equals , true )
+ c.Check (autoRefreshAssertions , check.Equals , true )
}
func (s *apiSuite ) TestRefreshMany (c *check .C ) {
refreshSnapDecls := false
- assertstateRefreshSnapDeclarations = func (s *state.State , userID int ) error {
+ assertstateRefreshSnapDeclarations = func (st *state.State , userID int ) error {
refreshSnapDecls = true
- return nil
+ return assertstate. RefreshSnapDeclarations (st, userID)
}
snapstateUpdateMany = func (s *state.State , names []string , userID int ) ([]string , []*state.TaskSet , error ) {
@@ -2961,9 +2964,9 @@ func (s *apiSuite) TestRefreshMany(c *check.C) {
func (s *apiSuite ) TestRefreshMany1 (c *check .C ) {
refreshSnapDecls := false
- assertstateRefreshSnapDeclarations = func (s *state.State , userID int ) error {
+ assertstateRefreshSnapDeclarations = func (st *state.State , userID int ) error {
refreshSnapDecls = true
- return nil
+ return assertstate. RefreshSnapDeclarations (st, userID)
}
snapstateUpdateMany = func (s *state.State , names []string , userID int ) ([]string , []*state.TaskSet , error ) {
@@ -4844,7 +4847,13 @@ func (s *postCreateUserSuite) makeSystemUsers(c *check.C, systemUsers []map[stri
assertAdd (st, model)
for _ , suMap := range systemUsers {
- su , err := signers[suMap[" authority-id" ].(string )].Sign (asserts.SystemUserType , suMap, nil , " " )
+ headers := make (map [string ]interface {})
+ for k , v := range suMap {
+ headers[k] = v
+ }
+ headers[" since" ] = time.Now ().Format (time.RFC3339 )
+ headers[" until" ] = time.Now ().Add (24 * 30 * time.Hour ).Format (time.RFC3339 )
+ su , err := signers[suMap[" authority-id" ].(string )].Sign (asserts.SystemUserType , headers, nil , " " )
c.Assert (err, check.IsNil )
su = su.(*asserts.SystemUser )
// now add system-user assertion to the system
@@ -4869,8 +4878,6 @@ var goodUser = map[string]interface{}{
" name" : " Boring Guy" ,
" username" : " guy" ,
" password" : " $6$salt$hash" ,
- " since" : time.Now ().Format (time.RFC3339 ),
- " until" : time.Now ().Add (24 * 30 * time.Hour ).Format (time.RFC3339 ),
}
var partnerUser = map [string ]interface {}{
@@ -4882,8 +4889,6 @@ var partnerUser = map[string]interface{}{
" name" : " Partner Guy" ,
" username" : " partnerguy" ,
" password" : " $6$salt$hash" ,
- " since" : time.Now ().Format (time.RFC3339 ),
- " until" : time.Now ().Add (24 * 30 * time.Hour ).Format (time.RFC3339 ),
}
var badUser = map [string ]interface {}{
@@ -4896,8 +4901,6 @@ var badUser = map[string]interface{}{
" name" : " Random Gal" ,
" username" : " gal" ,
" password" : " $6$salt$hash" ,
- " since" : time.Now ().Format (time.RFC3339 ),
- " until" : time.Now ().Add (24 * 30 * time.Hour ).Format (time.RFC3339 ),
}
var unknownUser = map [string ]interface {}{