summaryrefslogtreecommitdiff
path: root/spec/django/signup.js
blob: 383dd141044881f9748ed441d62edf93a7ba7ae2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
describe("Signup", function() {

  beforeEach(function() {
    this.srp = new SRP();
    specHelper.setupFakeXHR.apply(this);
  });

  afterEach(function() {
    this.xhr.restore();
  });

  it("has a register function", function() {
    expect(typeof this.srp.register).toBe('function');
  });

  it("receives the salt from /register/salt", function(){
    var callback = sinon.spy();
    this.srp.remote.sendVerifier = callback;
    this.srp.register();
    this.expectRequest('register/salt/', "I=user")
    this.respondXML("<salt>5d3055e0acd3ddcfc15</salt>");
    expect(callback).toHaveBeenCalledWith(this.srp.session, this.srp.registered_user);
  });

  it("identifies after successful registration (INTEGRATION)", function(){
    var callback = sinon.spy();
    this.srp.identify = callback;
    this.srp.register();
    this.expectRequest('register/salt/', "I=user")
    this.respondXML("<salt>5d3055e0acd3ddcfc15</salt>");
    this.expectRequest('register/user/', "v=adcd57b4a4a05c2e205b0b7b30014d9ff635d8d8db2f502f08e9b9c132800c44");
    this.respondXML("<ok />");
    expect(callback).toHaveBeenCalled();
  });

  it("identifies after successful registration with JSON (INTEGRATION)", function(){
    var callback = sinon.spy();
    this.srp.identify = callback;
    this.srp.register();
    this.expectRequest('register/salt/', "I=user")
    this.respondJSON({salt: "5d3055e0acd3ddcfc15"});
    this.expectRequest('register/user/', "v=adcd57b4a4a05c2e205b0b7b30014d9ff635d8d8db2f502f08e9b9c132800c44");
    this.respondJSON({ok: true});
    expect(callback).toHaveBeenCalled();
  });


});