(stateDir: string)
| 112 | } |
| 113 | |
| 114 | function testExpiredTokenCleanup(stateDir: string): void { |
| 115 | const store = new SqliteOAuthStore(stateDir); |
| 116 | const client = new SqliteOAuthClientsStore(store, oauthConfig.allowedRedirectHosts).registerClient({ |
| 117 | redirect_uris: [redirectUri], |
| 118 | }); |
| 119 | const expiredAt = Math.floor(Date.now() / 1000) - 1; |
| 120 | store.saveTokenPair({ |
| 121 | accessTokenHash: "expired-access-hash", |
| 122 | accessToken: { clientId: client.client_id, scopes: ["devspace"], expiresAt: expiredAt }, |
| 123 | refreshTokenHash: "expired-refresh-hash", |
| 124 | refreshToken: { clientId: client.client_id, scopes: ["devspace"], expiresAt: expiredAt }, |
| 125 | }); |
| 126 | store.close(); |
| 127 | |
| 128 | const reopened = new SqliteOAuthStore(stateDir); |
| 129 | try { |
| 130 | assert.equal(reopened.getAccessToken("expired-access-hash"), undefined); |
| 131 | assert.equal(reopened.getRefreshToken("expired-refresh-hash"), undefined); |
| 132 | } finally { |
| 133 | reopened.close(); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | function testTransactionalTokenRotation(stateDir: string): void { |
| 138 | const store = new SqliteOAuthStore(stateDir); |
no test coverage detected