Skip to content

Commit c7901f0

Browse files
f - session: add migration code from kvdb to SQL
1 parent ef90ce7 commit c7901f0

File tree

2 files changed

+0
-32
lines changed

2 files changed

+0
-32
lines changed

session/sql_migration.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ func migrateSessionsToSQLAndValidate(ctx context.Context,
111111

112112
overrideSessionTimeZone(kvSession)
113113
overrideSessionTimeZone(migratedSession)
114-
overrideMacaroonRecipe(kvSession, migratedSession)
115114

116115
if !reflect.DeepEqual(kvSession, migratedSession) {
117116
diff := difflib.UnifiedDiff{
@@ -329,28 +328,3 @@ func overrideSessionTimeZone(session *Session) {
329328
session.RevokedAt = fixTime(session.RevokedAt)
330329
}
331330
}
332-
333-
// overrideMacaroonRecipe overrides the MacaroonRecipe for the SQL session in a
334-
// certain scenario:
335-
// In the bbolt store, a session can have a non-nil macaroon struct, despite
336-
// both the permissions and caveats being nil. There is no way to represent this
337-
// in the SQL store, as the macaroon permissions and caveats are separate
338-
// tables. Therefore, in the scenario where a MacaroonRecipe exists for the
339-
// bbolt version, but both the permissions and caveats are nil, we override the
340-
// MacaroonRecipe for the SQL version and set it to a MacaroonRecipe with
341-
// nil permissions and caveats. This is needed to ensure that the deep equals
342-
// check in the migration validation does not fail in this scenario.
343-
func overrideMacaroonRecipe(kvSession *Session, migratedSession *Session) {
344-
if kvSession.MacaroonRecipe != nil {
345-
kvPerms := kvSession.MacaroonRecipe.Permissions
346-
kvCaveats := kvSession.MacaroonRecipe.Caveats
347-
348-
if kvPerms == nil && kvCaveats == nil {
349-
migratedSession.MacaroonRecipe = &MacaroonRecipe{}
350-
} else if kvPerms == nil {
351-
migratedSession.MacaroonRecipe.Permissions = nil
352-
} else if kvCaveats == nil {
353-
migratedSession.MacaroonRecipe.Caveats = nil
354-
}
355-
}
356-
}

session/sql_migration_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@ func TestSessionsStoreMigration(t *testing.T) {
7373
)
7474
require.NoError(t, err)
7575

76-
// Since the SQL store can't represent a session with
77-
// a non-nil MacaroonRecipe, but with nil caveats and
78-
// perms, we need to override the macaroon recipe if the
79-
// kvSession has such a recipe stored.
80-
overrideMacaroonRecipe(kvSession, sqlSession)
81-
8276
assertEqualSessions(t, kvSession, sqlSession)
8377
}
8478

0 commit comments

Comments
 (0)