Example #1
0
  it('rebuilds the linode', async () => {
    const page = mount(
      <RebuildPage
        dispatch={dispatch}
        distributions={api.distributions}
        linodes={api.linodes}
        params={{ linodeLabel: 'test-linode' }}
      />
    );

    dispatch.reset();

    page.find('.LinodesDistribution').first().simulate('click');
    page.find('.LinodesLinodeRebuildPage-password input').simulate('change',
      { target: { value: 'new password' } });

    await page.instance().onSubmit();

    const fn = dispatch.firstCall.args[0];
    await expectRequest(fn, '/linode/instances/1234/rebuild', {
      method: 'POST',
      body: {
        distribution: 'linode/debian7',
        root_pass: 'new password',
      },
    });

    const fn2 = dispatch.secondCall.args[0];
    expectObjectDeepEquals(fn2, push('/linodes/test-linode'));
  });
Example #2
0
 ([fn]) => {
   const _dispatch = sinon.stub();
   fn(_dispatch, () => ({ api: { profile: {} } }));
   return expectRequest(_dispatch.firstCall.args[0], '/account/profile/tfa-enable', {
     method: 'POST',
   });
 },
Example #3
0
 ([fn]) => expectRequest(fn, `/nodebalancers/${genericNodeBalancer.id}`, {
   method: 'PUT',
   body: {
     client_conn_throttle: genericNodeBalancer.client_conn_throttle,
     label: genericNodeBalancer.label,
   },
 }),
Example #4
0
  it('creates a new NS record and closes the modal', async () => {
    const currentZone = api.dnszones.dnszones['1'];
    const close = sandbox.spy();
    const page = mount(
      <EditNSRecord
        dispatch={dispatch}
        zone={currentZone}
        close={close}
      />
    );

    const changeInput = (name, value) =>
      page.instance().setState({ [name]: value });

    changeInput('nameserver', 'ns1.tester1234.com');
    changeInput('subdomain', 'tester1234.com');
    changeInput('ttl', 3600);

    dispatch.reset();
    await page.find('Form').props().onSubmit();

    expect(dispatch.callCount).to.equal(1);
    expect(close.callCount).to.equal(1);

    const fn = dispatch.firstCall.args[0];
    await expectRequest(fn, `/dns/zones/${currentZone.id}/records/`, {
      method: 'POST',
      body: {
        target: 'ns1.tester1234.com',
        name: 'tester1234.com',
        ttl_sec: 3600,
        type: 'NS',
      },
    });
  });
Example #5
0
 ([fn]) => expectRequest(fn, '/domains/', {
   method: 'POST',
   body: {
     domain: 'test.com',
     type: 'slave',
     ips: ['1', '2', '3', '4'],
   },
 }),
Example #6
0
 ([fn]) => expectRequest(fn, `/account/users/${testUser.username}`, {
   method: 'PUT',
   body: {
     username: 'the-username',
     email: 'the-email',
     restricted: false,
   },
 }),
 ([fn]) => expectRequest(fn, '/account/tokens/', {
   method: 'POST',
   body: {
     label: 'My sweet new token',
     // Can't actually check on expiry because it's based off of $NOW which
     // leads to test failure
   },
 }),
Example #8
0
 ([fn]) => expectRequest(fn, '/support/tickets/', {
   method: 'POST',
   body: {
     linode_id: testLinode.id,
     summary: 'My new ticket!',
     description: 'This is my new description!',
   },
 }),
 ([fn]) => expectRequest(fn, `/domains/${currentZone.id}/records/${currentRecord.id}`, {
   method: 'PUT',
   body: {
     name: 'www.tester1234.com',
     target: 'www.othertester1234.com',
     ttl_sec: 3600,
     type: 'CNAME',
   },
 }),
Example #10
0
 ([fn]) => expectRequest(fn, `/domains/${currentZone.id}/records/${currentRecord.id}`, {
   method: 'PUT',
   body: {
     target: 'mx1.tester1234.com',
     name: 'tester1234.com',
     priority: 1,
     type: 'MX',
   },
 }),
Example #11
0
 ([fn]) => expectRequest(fn, '/networking/ip-assign', {
   method: 'POST',
   body: {
     region: testLinode.region.id,
     assignments: [
       { address: ipA.address, linode_id: ipB.linode_id },
       { address: ipB.address, linode_id: ipA.linode_id },
     ],
   },
 }),
Example #12
0
  it('dispatches on item click', async () => {
    const dispatch = sinon.spy();
    const dropdown = shallow(
      <StatusDropdown linode={linodes.linodes[1235]} dispatch={dispatch} />
    );

    dropdown.find('.StatusDropdown-toggle').simulate('click');
    expect(dropdown.find('.StatusDropdown--open').length).to.equal(1);

    dropdown.find('.StatusDropdown-item').first().simulate('mousedown');
    const reboot = dispatch.firstCall.args[0];
    await expectRequest(reboot, '/linode/instances/1235/reboot', { method: 'POST' });
  });
Example #13
0
      async ([fn]) => {
        const _dispatch = sinon.stub();
        const promiseAllStub = sinon.stub(Promise, 'all');
        fn(_dispatch);

        expect(promiseAllStub.callCount).to.equal(1);
        expect(_dispatch.callCount).to.equal(3);

        let _fn = _dispatch.getCall(1).args[0];
        await expectRequest(_fn, `/linode/instances/${ipA.linode_id}/ips`);

        _fn = _dispatch.getCall(2).args[0];
        await expectRequest(_fn, `/linode/instances/${ipB.linode_id}/ips`);

        _fn = _dispatch.getCall(0).args[0];
        _dispatch.reset();
        _dispatch.returns({ total_pages: 1, linodes: [], total_results: 0 });
        await _fn(_dispatch, () => state);
        _fn = _dispatch.firstCall.args[0];
        await expectRequest(_fn, '/linode/instances/?page=1', undefined, {
          linodes: [],
        });
      },
Example #14
0
  it('should delete app', async () => {
    const client = clients[1];
    const page = mount(
      <MyApplication
        dispatch={dispatch}
        client={client}
      />
    );

    dispatch.reset();

    await page.instance().deleteApp();
    const fn = dispatch.firstCall.args[0];
    await expectRequest(fn, '/account/clients/1', { method: 'DELETE' });
  });
Example #15
0
  it('preloads the configs', async () => {
    const _dispatch = sandbox.stub();
    _dispatch.returns({ id: 1241 });
    await IndexPage.preload({ dispatch: _dispatch, getState: () => state },
                            { linodeLabel: 'test-linode-7' });

    let fn = _dispatch.secondCall.args[0];
    _dispatch.reset();
    _dispatch.returns({ total_pages: 1, configs: [], total_results: 0 });
    await fn(_dispatch, () => state);
    fn = _dispatch.firstCall.args[0];
    await expectRequest(fn, '/linode/instances/1241/configs/?page=1', undefined, {
      configs: [],
    });
  });
  it('changes password', async () => {
    const page = shallow(
      <AuthenticationPage
        dispatch={dispatch}
      />
    );

    page.instance().setState({ password: 'thePassword' });
    await page.instance().passwordOnSubmit();
    expect(dispatch.callCount).to.equal(1);
    const fn = dispatch.firstCall.args[0];

    await expectRequest(fn, '/account/profile/password', {
      method: 'POST',
      body: { password: 'thePassword', expires: null },
    });
  });
Example #17
0
 it('attempts to delete config', async () => {
   const panel = shallow(
     <ConfigPanel
       params={{ linodeLabel: 'test-linode-4' }}
       dispatch={dispatch}
       linodes={linodes}
     />
   );
   const actionBtn = panel.
     find('.LinodesLinodeSettingsComponentsConfigPanel-delete').at(0);
   actionBtn.simulate('click', { preventDefault: () => {} });
   expect(dispatch.callCount).to.equal(1);
   await dispatch.args[0][0].body.props.onOk();
   const fn = dispatch.secondCall.args[0];
   dispatch.reset();
   await expectRequest(fn, '/linode/instances/1238/configs/12345', { method: 'DELETE' });
 });
Example #18
0
  it('creates a new application', async () => {
    const page = shallow(
      <CreateApplication
        dispatch={dispatch}
        close={dispatch}
      />
    );

    const changeInput = (id, value) =>
      page.find('Input').find({ id }).simulate('change', { target: { value, name: id } });

    changeInput('label', 'My new client');
    changeInput('redirect', 'http://example.com');
    const thumbnail = { size: (MAX_UPLOAD_SIZE_MB - 0.5) * 1024 * 1024 };
    page.instance().setState({ thumbnail });

    dispatch.returns({ id: 1 });
    await page.props().onSubmit();

    // One call to save the data, one call to save the thumbnail, one call to close.
    expect(dispatch.callCount).to.equal(3);

    let fn = dispatch.firstCall.args[0];
    await expectRequest(fn, '/account/clients/', {
      method: 'POST',
      body: {
        label: 'My new client',
        redirect_uri: 'http://example.com',
      },
    });

    // This is not a normal request, so we are not able to test it using expectRequest.
    fn = dispatch.secondCall.args[0];
    const fetchStub = sandbox.stub(fetch, 'fetch').returns({ json: () => {} });
    dispatch.reset();
    await fn(dispatch, () => state);

    expect(fetchStub.callCount).to.equal(1);
    expect(fetchStub.firstCall.args[1]).to.equal('/account/clients/1/thumbnail');
    expectObjectDeepEquals(fetchStub.firstCall.args[2], {
      method: 'PUT',
      body: thumbnail,
      headers: { 'Content-Type': 'image/png' },
    });
  });
Example #19
0
  it('takes a snapshot', async () => {
    const page = shallow(
      <SummaryPage
        dispatch={dispatch}
        linodes={api.linodes}
        params={{ linodeLabel: 'test-linode-2' }}
      />
    );

    const takeSnapshot = page.find('.Backup').at(3).find('Button');
    expect(takeSnapshot.length).to.equal(1);

    dispatch.reset();
    takeSnapshot.simulate('click');

    const fn = dispatch.firstCall.args[0];
    await expectRequest(fn, '/linode/instances/1236/backups', { method: 'POST' });
  });
Example #20
0
  it('submits data onsubmit and closes modal for SRV record', async () => {
    const currentZone = api.dnszones.dnszones['1'];
    const currentRecord = currentZone._records.records[6];
    const close = sandbox.spy();
    const page = mount(
      <EditSRVRecord
        dispatch={dispatch}
        zone={currentZone}
        id={currentRecord.id}
        close={close}
      />
    );

    const changeInput = (name, value) =>
      page.instance().setState({ [name]: value });

    changeInput('service', '_ips');
    changeInput('protocol', '_udp');
    changeInput('target', 'ns2.service.com');
    changeInput('priority', 77);
    changeInput('weight', 7);
    changeInput('port', 777);
    changeInput('ttl', 3600);

    await page.find('Form').props().onSubmit();

    expect(dispatch.callCount).to.equal(1);
    expect(close.callCount).to.equal(1);

    const fn = dispatch.firstCall.args[0];
    await expectRequest(fn, `/dns/zones/${currentZone.id}/records/${currentRecord.id}`, {
      method: 'PUT',
      body: {
        service: '_ips',
        protocol: '_udp',
        target: 'ns2.service.com',
        priority: 77,
        weight: 7,
        port: 777,
        ttl_sec: 3600,
        type: 'SRV',
      },
    });
  });
  it('revoke token auth', async () => {
    const page = mount(
      <AuthorizedApplicationsPage
        dispatch={dispatch}
        tokens={tokens}
      />
    );

    dispatch.reset();

    const myApp = page.find('AuthorizedApplication');
    myApp.at(0).find('Button').first()
      .simulate('click');
    await page.instance().revokeApp(2);
    const fn = dispatch.firstCall.args[0];
    await expectRequest(fn, '/account/tokens/2', undefined, undefined, {
      method: 'DELETE',
    });
  });
Example #22
0
  it('submits data onsubmit and closes modal', async () => {
    const currentZone = api.dnszones.dnszones['1'];
    const close = sandbox.spy();
    const page = mount(
      <EditSOARecord
        dispatch={dispatch}
        zone={currentZone}
        close={close}
      />
    );

    const changeInput = (name, value) =>
      page.instance().setState({ [name]: value });

    changeInput('zone', 'tester1234.com');
    changeInput('group', 'tester-zones');
    changeInput('email', 'admin@tester1234.com');
    changeInput('defaultTTL', 3600);
    changeInput('refreshRate', 3600);
    changeInput('retryRate', 3600);
    changeInput('expireTime', 3600);

    await page.find('Form').props().onSubmit();

    expect(dispatch.callCount).to.equal(1);
    expect(close.callCount).to.equal(1);

    const fn = dispatch.firstCall.args[0];
    await expectRequest(fn, `/dns/zones/${currentZone.id}`, {
      method: 'PUT',
      body: {
        dnszone: 'tester1234.com',
        display_group: 'tester-zones',
        soa_email: 'admin@tester1234.com',
        ttl_sec: 3600,
        refresh_sec: 3600,
        retry_sec: 3600,
        expire_sec: 3600,
      },
    });
  });
Example #23
0
  it('renders timezones', async () => {
    const page = mount(
      <DisplayPage
        dispatch={dispatch}
        profile={profile}
      />
    );

    expect(page.find('option').length).to.equal(TIME_ZONES.length);
    expect(page.find('#timezone').props().value).to.equal('US/Eastern');

    page.instance().setState({ timezone: 'GMT' });
    await page.instance().timezoneOnSubmit();
    expect(dispatch.calledOnce).to.equal(true);
    const fn = dispatch.firstCall.args[0];

    await expectRequest(fn, '/account/profile', {
      method: 'PUT',
      body: { timezone: 'GMT' },
    });
  });
Example #24
0
  it('renders email', async () => {
    const page = mount(
      <DisplayPage
        dispatch={dispatch}
        profile={profile}
      />
    );

    dispatch.reset();
    const email = page.find('#email');
    expect(email.props().value).to.equal('example@domain.com');

    page.instance().setState({ email: 'example2@domain.com' });
    await page.instance().emailOnSubmit();
    expect(dispatch.calledOnce).to.equal(true);
    const fn = dispatch.firstCall.args[0];

    await expectRequest(fn, '/account/profile', {
      method: 'PUT',
      body: { email: 'example2@domain.com' },
    });
  });
Example #25
0
  it('resize the linode', async () => {
    const page = mount(
      <ResizePage
        dispatch={dispatch}
        types={api.types}
        linodes={api.linodes}
        params={{ linodeLabel: 'test-linode' }}
      />
    );

    dispatch.reset();

    page.find('.plan').first().simulate('click');
    await page.instance().onSubmit();

    const fn = dispatch.firstCall.args[0];
    await expectRequest(fn, '/linode/instances/1234/resize', {
      method: 'POST',
      body: {
        type: 'linode1024.5',
      },
    });
  });
Example #26
0
  it('submits data onsubmit and closes modal', async () => {
    const currentZone = api.dnszones.dnszones['1'];
    const currentRecord = currentZone._records.records[1];
    const close = sandbox.spy();
    const page = mount(
      <EditARecord
        dispatch={dispatch}
        zone={currentZone}
        id={currentRecord.id}
        close={close}
      />
    );

    const changeInput = (name, value) =>
      page.instance().setState({ [name]: value });

    changeInput('hostname', 'tee');
    changeInput('ip', '4.4.4.4');
    changeInput('ttl', 1);

    await page.find('Form').props().onSubmit();

    expect(dispatch.callCount).to.equal(1);
    expect(close.callCount).to.equal(1);

    const fn = dispatch.firstCall.args[0];
    await expectRequest(fn, `/dns/zones/${currentZone.id}/records/${currentRecord.id}`, {
      method: 'PUT',
      body: {
        target: '4.4.4.4',
        name: 'tee',
        ttl_sec: 1,
        type: 'A',
      },
    });
  });
Example #27
0
  it('creates a new AAAA record and closes the modal', async () => {
    const currentZone = api.dnszones.dnszones['1'];
    const close = sandbox.spy();
    const page = mount(
      <EditARecord
        dispatch={dispatch}
        zone={currentZone}
        close={close}
      />
    );

    const changeInput = (name, value) =>
      page.instance().setState({ [name]: value });

    changeInput('ip', '1.1.1.8');
    changeInput('hostname', 'too');
    changeInput('ttl', 1);
    changeInput('type', 'AAAA');

    dispatch.reset();
    await page.find('Form').props().onSubmit();

    expect(dispatch.callCount).to.equal(1);
    expect(close.callCount).to.equal(1);

    const fn = dispatch.firstCall.args[0];
    await expectRequest(fn, `/dns/zones/${currentZone.id}/records/`, {
      method: 'POST',
      body: {
        target: '1.1.1.8',
        name: 'too',
        ttl_sec: 1,
        type: 'AAAA',
      },
    });
  });
Example #28
0
 ([fn]) => expectRequest(fn, '/linode/instances/1234', {
   method: 'PUT',
   body: { group: 'foobar', label: 'my-new-label' },
 }),
Example #29
0
 ([fn]) => expectRequest(fn, '/linode/instances/1234', {
   method: 'PUT',
   body: { group: 'foobar', label: testLinode.label },
 }),
Example #30
0
 ([fn]) => expectRequest(fn, '/linode/instances/1234/rescue', { method: 'POST' }),