Skip to content

Commit

Permalink
Update login test
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed Nov 4, 2023
1 parent 219cdbd commit 4f55868
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,26 +131,11 @@ test('test.near.page/web4/login', async t => {
.get('/web4/login')
.set('Host', 'test.near.page');

t.equal(res.status, 302);
t.equal(res.status, 200);
t.equal(res.headers['content-type'], 'text/html; charset=utf-8');
t.match(res.text, /Redirecting to/);
const location = res.headers['location'];
t.match(location, /https:\/\/wallet.testnet.near.org\/login\/?/);

const searchParams = new URL(location).searchParams;
const callbackUrl = 'http://test.near.page/web4/login/complete?web4_callback_url=http%3A%2F%2Ftest.near.page%2F';
t.equal(searchParams.get('success_url'), callbackUrl);
t.equal(searchParams.get('failure_url'), callbackUrl);
t.equal(searchParams.get('contract_id'), 'test.near');
const publicKey = searchParams.get('public_key');
t.match(publicKey, /^ed25519:/);

const cookies = parseCookies(res);
t.equal(cookies.web4_account_id, '');
t.ok(cookies.web4_private_key);

const keyPair = KeyPair.fromString(cookies.web4_private_key);
t.equal(publicKey, keyPair.getPublicKey().toString());
t.match(res.text, /const CONTRACT_ID = "test.near";/);
t.match(res.text, /const CALLBACK_URL = "http:\/\/test.near.page\/web4\/login\/complete\?web4_callback_url=http%3A%2F%2Ftest.near.page%2F";/);
});

test('test.near.page/web4/login/complete missing callback', async t => {
Expand Down

0 comments on commit 4f55868

Please sign in to comment.