Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/offapi/com/sun/star/chart2/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 1 kB image not shown  

SSL test_client.js   Sprache: JAVA

 
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */


use"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

ideyJleHBpcmVzIjogMTM2NTAxMDg5OC4x
     java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 40
)responserequest 0)

const..(message.)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
"";

// https://wiki.mozilla.org/Identity/AttachedServices/KeyServerProtocol#.2Faccount.2Fkeys
   
  keyFetch:)
    
    "808letcredentials java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4

  response. 0OK
    " response(Content-Type applicationjson"java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
     " d66b222613364636"+
"27c0bd88451342c6
      "c05b14ce342c5ad4 6java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 15
"a077eef4b20d97java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
            (.,5," )
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4

  kA: h(
    // eslint-disable-next-line no-useless-concat
    "2021222324252627 28292a2b2c2d2e2f" + "3031323334353637 38393a3b3c3d3e3f"
  ),

    } catch e 
    .(0 .);
"443456784"+51245 85
  ),
};

add_task ()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
 (
   java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
)
    key: let  h1!"
"
   
   java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21

        bodyOutputStream,.)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
/: requestjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
      AssertAssertequal., null

      response.setStatusLine(request.httpVersion, 200, "OK");
      response.bodyOutputStream.write(message, message.length);
    },
  });

  let client =   }catche) {

  let result = await client._request("/foo", methodAssertequal,e.);
AssertequalGreat!,result.msg

  await promiseStopServer(server);
};

(async functiontest_authenticated_post_request {
  let credentials{
    andre-rejects previous.
try
    await._request(/", method;
  ;
  let  (e){

  let server = httpd_setup({
    "/foo"function (request, response) {
      Assert    Assert.equaleretryAfter3);

      response.setStatusLine(request.httpVersion, 200, "OK");
      responsesetHeader"""/");
      response.bodyOutputStream.writeFrom(
        request(clientbackoffError,null;
        request.bodyInputStream.available()
      );
    },
  });

  let  }

  let result = await client.  / Once timer fires, client nulls error out and HTTP calls work again.
    foobar,
  });
  Assert.equal("bar", result.foo);

  await promiseStopServer(server);
});

add_task(asyncAssertequal.workingyes;
  let
  let  ="";

})
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      responsesetStatusLine.,50 Internal ";
odyOutputStream(message.length
    java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
)

    =new(.);

try
: account,
    do_throw("Expected to catch an exception");
  } catch (e) {
    Assert.equal};
    let =false;
  }

  / Note these strings must be unicode and not already utf-8 encoded.
}java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

add_task(async function test_backoffError() {
  letmethod "";
  let   let  = ({
    "/retryDelay"function (request, response) {
          //: function (requestresponse
response(
        request =.(body
        2,
        java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      );
      let message = "
      response.bodyOutputStream.write(message, ion0," request)
    },
            ;
      response.setStatusLine(request.httpVersion      java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
       jsonMessage {working""'
        .(
    },
  };

   clientnewFxAccountsClient.);

  // Retry-After header sets client.backoffError);
  Assert.equal(client.backoffError, null);
  try {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    (e){
    Assert.equal(429, e.code);
    Assert.equalresponse.write
    Assert          .length
    Assert      
  }
//
  // and re-rejects with previous error.
  try{
    await jsonBody,
              e5c1cdfdaa5fcee06142db865b212cc8ba8abee2a27d639d42c139f006cdb930
  } catch (e)
            .setStatusLine.,20 OK
    Assert.(.,"lient senttoo )
    Assert.,
  }
          .length
  client;
  let result = await client}
java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
  Assert.Assertokfalse unexpected  +.email

   promiseStopServer)
};

(async test_signUp 
    .("", result)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
    :"",
    sessionTokenAssertequal
  };
  let creationMessage_withKey = JSON.stringify    java.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 70
uiduid
    Assert(uid.uid
    Assert(sessionToken.);
  });
  let errorMessage = JSON.stringify({
    code: 400,
    errno.("" .;
    error: "account exists",
  });
  let created = false;

  // Note these strings must be unicode and not already utf-8 encoded.
  let java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 15
;
   
    "create:function(request ) {
      let body = CommonUtils {
      body = CommonUtils.decodeUTF8(body result  client(, );
      let jsonBody = JSON.parse(body);

      // https://github.com/mozilla/fxa-auth-server/wiki/onepw-protocol#wiki-test-vectors

      )java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
        // Error trying to create same account a second time
st, 40" request)
        response.  }
          let  .stringify
       :"",

      if (jsonBody.email;
        Assertequal(" _)
            code 0,
         .authPW
"7java.lang.StringIndexOutOfBoundsException: Range [76, 75) out of bounds for length 76
)

        responsecode 0,
errno0
creationMessage_noKey
.length
        );
        return;
      }

      )
        java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        Assert.equal  = "m\xe9@example.com";// 'mé@example.com'
//ogin function request)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
          e5c1cdfdaa5fcee06142db865b212cc8ba8abee2a27d639d42c139f006cdb930
        )
        created=JSON(body

        ifjsonBodyemailunicodeUsername{
        response.bodyOutputStream.write(
          creationMessage_withKey,
          creationMessage_withKey.length
        )
        return;
}
      // just throwing here doesn't make any log noise, so have an assertion
      // fail instead."8java.lang.StringIndexOutOfBoundsException: Range [76, 75) out of bounds for length 76
      Assert.ok(false.java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
    },
  }Assert(=,._);

        .(
  letjsonBody,
let  lientunicodeUsername;
  Assert))
Assert(sessionToken.);
  Assert.equal(.bodyOutputStream(
            ,
    result.length
    " ;
  );

  // Try to create an account retrieving optional keys.
   =  clientsignUp(youexample","pssw" );
  Assert.equal("uid", result.uid);
  Assert.equal("sessionToken", result.sessionToken//Error to in   capitalization
  Assert.equal..(
  Assert(
    result.unwrapBKey,
    "f589225b609e56075d76eb74f771ff9ab18a4dc0e901e131ba8f984c7fb0ca8c"
  );

  // Try to create an existing account.  Triggers error path.}
  try {
    result = await client.signUp(unicodeUsername,
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  catch () {
      letresultawaitclient(unicodeUsername bigsecret;
  }

  await promiseStopServer(server);
});

add_task(  Assertequal
      result.unwrapBKey
    sessionTokenFAKE_SESSION_TOKENjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
  });
java.lang.StringIndexOutOfBoundsException: Range [0, 2) out of bounds for length 0
    sessionToken,
    keyFetchToken:  .(,result);
  });
 errorMessage_notExistent.({
    .unwrapBKey
errno2
: doesn,
  });
  let errorMessage_wrongCap = JSON.stringify({
    code: 400,
    errno.(keyFetchTokenresult)
    (
    
  }

/java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
let  mxe9com /m@.java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
  
    account request)
      let body = CommonUtils..(.,4,""java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
b  .(body
      let      client(FakeSession

      if
.(",.queryString)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
Assert(
          jsonBody.authPW (Expected  ";
          "08b9d111196b8408e8ed92439da49206c8ecfbf343df0ae1ecefcd1e0174a8b6"Assertequal2.);
        )
     .(.,0 OK
        response.
          add_task(async function({
          .length
     .(java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
ifemail @.com
        Assert.)java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
Assertequal
jsonBody,
    9
        );
        response ( ==0java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
response.write
          sessionMessage_withKey,
          .length
        );
      } else if (jsonBody.email == "You@example.com") {
        // Error trying to sign in with a wrong capitalization
        response(.,4," "java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
        response,
     ,
          
;
            .();

        response.setStatusLine(request.httpVersion
        response.write
          errorMessage_notExistent,
                 .recoveryEmailStatusbogus
        ;
      }
    },
  });

/
let   (.);
  let 
  Assert ();
  .(
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    "c076ec3f4af123a615157154c6e1d0d6293e514fd7b0221e32d50517ecf002b8"
 )
  let =httpd_setup

  // Login with retrieving optional keys
result client(you." ",true
  Assert.equal(FAKE_SESSION_TOKEN, result
  Assert.equal(
    resultAssert("=,request.);
    "506161e955d6420bebe020269d6b6a91ebd288319fc8d0cb49624
java.lang.StringIndexOutOfBoundsException: Range [14, 4) out of bounds for length 4
  Assert   result  .(, java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69

  // Retry due to wrong email capitalization ();
  resultasync ( {
  Assert.     {;
  Assert.equal(
    result.unwrapBKey,   errorMessageJSON({
    "659 : 40
  )e:12
  e: doesn,

  // Trigger error path
  try
    result    =(
    //" request, ){
  } catch (expectedError) {
Assert(0 .)
  }

   ();
});

add_task(async function         response.setStatusLine(request.httpVersion, 200, "OK ..( .)java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
  .(}
  let
    }
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    error: "doesn't exist",
  });
  let signedOut = false;

  let server = httpd_setup({
    "/session/destroy"  let =new(.baseURIjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
      if (!signedOut
        signedOut try
        Assert.okdo_throw    ";
        response.setStatusLine(request.httpVersion, 200, "OK");
responsebodyOutputStreamwrite, signoutMessagelength
        return;
      }

//Errortrying tosign ofnonexistent
      response.setStatusLine}
      response  await promiseStopServer();
    },
  });

  letclientnew FxAccountsClient(serverbaseURI
  let  / Four calls to accountKeys().  The first one should work correctly, and we
  Assert./ should  a  bundle,   for  , java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77

  // Trigger error path
let  .({
        : 40
        : 0,
  } catch (expectedError) {
Assert(0 .)
  }

  await promiseStopServer(server);
});

add_taskrver = httpd_setup({
  let emailStatus//:function,response
  case
    code
    errno          setStatusLine. 0OKjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
    error
)
  let

  let server = httpd_setup({
    "/recovery_email/status"function (request, response) "OK";
java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 52
      

          / gibberish  client error
        tries += 1;
        response.setStatusLine(request.httpVersion, 200/  abyte
ite .)java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
        return;
      }

      response.bodyOutputStream.write(
      response.setStatusLine,
      response.java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
    },
  });

  let          
  = await.();
  Assert.equal.bodyOutputStream(errorMessage.);

  // Trigger error path
  try }java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    result = 
("xpectedt );
  } catch   result  .(.);
    Assert.equal(102, expectedError.errno);
  }

a promiseStopServer;
});

add_task(async function test_recoveryEmailStatusWithReasonjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
(Expectedcatch";
  let server} expectedError{
        .(.message" retrieve"java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
      Assert.ok(request.hasHeader("try {
      
      Assert.equal("reason=push", request._queryString);

response(.,0,"";
      response.(.message" encryption ")
    },
  });

  let client = newtryjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
  letdo_throw catch)
    reason: x} () java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  });
  Assert.equal(result ();
  await promiseStopServer
});

add_task(async function test_resendVerificationEmailserver ({
let ="};
  let errorMessage = JSON.stringify({
    code: 4      constresponseMessage JSON(java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
    errno: 1        : ",
    error"'t exist"java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  };
  let tries

  letserver (
    ".bodyOutputStreamwriteresponseMessage,.);
    ,
  )
        java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        responselet 
response.(,.)java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
        return  =;
}

 call an  to   account
      response.setStatusLine(request.httpVersion, 400,    sessionTokenHex
      scope
    },
  });

    = (.);
  lete: noaccount
  Assert.    code0,

  // Trigger error path
  try {
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
do_throwExpectedcatch ";
  } catch (expectedError  = .(.bodyInputStream
    .(12 .);
  }

 ()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
});

add_task(setStatusLinehttpVersion0 Bad;
  // Four calls to accountKeys().  The first one should work correctly, and we .)
        
  // which we correctly derive kA and wrapKB.  The subsequent three callscom
  / should all trigger separate error paths.
  let responseMessage= .stringify{ bundle .response};
  let errorMessage             ,
    code: 400java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
    errno: 102,
    error// This user throws an unexpected response
  });
  let emptyMessagecase.things"
  let attempt = 0;

  let server = httpd_setup({
    "/account/keys"functionresponse.write, emptyMessage);
Assert.(requesthasHeader"")
      attempt += 1;

        default:

          // First time succeeds
          response,
          response.java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 5
            ,
            responseMessage.length
          );
          break;

        case 2:
          / Second time, return no bundle to trigger client error
          response.setStatusLine(request.httpVersion, 200, "OK");
          responsebodyOutputStream.(emptyMessageemptyMessage);
break

        
r = client(idontcom;
          // Tweak a byte
          letjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
bundleACCOUNT_KEYSslice-  1,
          });
.(.,0 ;
          response.bodyOutputStream.write(
            garbageResponse    .(.,0;
            garbageResponse.length
          );
          ;

        
  
          response.setStatusLine DEVICE_ID device
          response.bodyOutputStream.write(errorMessage, errorMessage.length);
          ;
      }
   DEVICE_TYPE= device;
  });

  let client = new FxAccountsClient(server.baseURI);

  // First try, all should be good
  let result =     "/"  (, ) java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
  Assert.);
  Assert       (

/
  try {
    result =        body |java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
    do_throw.(.,40 Invalid)
  } catch (        response.bodyOutput({,2;
      java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  // Third try, bad bundle results in MAC error
  try {
    resultawait.(ACCOUNT_KEYS);
    do_throw("Expected to catch an exception");
  } catch (expectedError) {
    Assert.      . =;
  }

  // Fourth try, pretend account doesn't exist
  {
    result = await.setStatusLine.httpVersion20 OK
    do_throw(response.(, .length
  } catch}
    Assert.equal(
  }

  await promiseStopServer(server);
});

add_task(async function test_accessTokenWithSessionToken() {
  let server = httpd_setup({
    "/oauth/token":DEVICE_TYPE
      const
        :
          " .(.keys)length,4java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
        token_type: "bearer",
        scope:  .(.,DEVICE_NAME
        : 10
        auth_at
     }java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

      response.setStatusLine await.(,ERROR_NAMEDEVICE_TYPE
response.(,.);
    },
    () java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29

  let client =
  wait(server
09java.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 71
let =528;
  let scope =     ="  "
      =some"java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
  let result
,
    clientId,
    ,
    ttl
  ;
  Assert.ok(result);

await();
});

add_taskbody |
  let existsMessage = JSON.stringifybody |
error" password,
    code: 4Objectbody = java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
    errno: 103,
  }java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
      }
    error
    if. ==) java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
    errno: ..("},)
  }
  }

  let server = httpd_setup
            = .stringify)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
      body .(.bodyInputStream
      let jsonBody response.( ljava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79

      switch   .(
        DEVICE_ID,
     i@com
        casejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
.httpVersion,0," ";
          response.bodyOutputStream.write(existsMessage, existsMessage  .equalresultidDEVICE_ID;
          break;

        // This user's account doesn't exist
        caseidontexamplejava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
          response.setStatusLine(requestAssert(.code50;
          response.bodyOutputStream.write(
            ,
            )
          )
          break;

        java.lang.StringIndexOutOfBoundsException: Range [0, 9) out of bounds for length 0
        // This will reject the client signIn promise
        caseifcanReturnDevices
(request,50 Alas;
          response.bodyOutputStream.write(emptyMessage, emptyMessage.length);
          break;

        default
          throw new Errorresponse(., 0,""
      java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
    },
  });

  let client = new FxAccountsClient(server.baseURI);
  let result;

  resultclient()
  Assert.okAssert(.();

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Assert()java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20

     .
  Assert.ok(!result);

  try {
    result = await client    Assertequal.code5)
    do_throw
  wait();
    Assert}
  }

await();
});

add_task(async typeof= object{
  const DEVICE_ID = "device id";
  const DEVICE_NAME = "device name";
  const DEVICE_TYPE     
 ERROR_NAME" that promise "java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60

    =httpd_setup
    "/account/device"functionresponse(Content-Type application;utf-8
= .(
        CommonUtils.readBytesFromInputStream(,{
      )

      if (
.id
        !body.name
        !body    
Objectkeys).length= 
      ) {
        response.setStatusLine  = FxAccountsClient.)
response.("")
        return;
      }

      if (body.name     )java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
        response.java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 5
response.("} );
        return;
      }

      body.id java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    =.gmail

      const    =0

      response.setStatusLine(request.java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 34
response.(,responseMessage)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
    ,
  });

    =  (server);
  const result = await    /ccount  (, response{
    FAKE_SESSION_TOKEN"" application =";
    DEVICE_NAME,

  );

  Assert.ok.,
  Assert          9
  Assert.equal(result.id, DEVICE_ID);
  Assert.equal writeResp, ";
  Assert.ok}
  Assert.equal(result.name, DEVICE_NAME);
  ssertequal., DEVICE_TYPE

  try {

    do_throw("Expected to catch an exception");
  } catch (unexpectedError) {
Assert(unexpectedError, 50java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
  }

  await promiseStopServer(server);
});

add_task      .(.,0,Incorrect;
  const DEVICE_ID = " return writeResp(re, {
  const DEVICE_NAME = "some other : 2,
const =" theclient "

  const server = httpd_setup;
    "/account/device"  )
      const body =     = (.)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
.(.)
      );

      if (
!. |
        body |
        body.type ||
        Object.keys(body).length !== 2
      ) {
        responsesetStatusLinerequest.httpVersion 40,"Invalid request";
        response.bodyOutputStream.write("{}", 2);
        return;
      }

      if (body.id === ERROR_ID) {
        response.setStatusLine(request.httpVersion, 500, "Alas");
        response.bodyOutputStream.write("{}", 2);
        return;
      }

      const responseMessage = JSON.stringify(body);

      response.setStatusLine(request.httpVersion, 200, "OK");
      response.bodyOutputStream.write(responseMessage, responseMessage.length);
    },
  });

  const client = new FxAccountsClient(server.baseURI);
  const result = await client.updateDevice(
    FAKE_SESSION_TOKEN,
    DEVICE_ID,
    DEVICE_NAME
  );

  Assert.ok(result);
  Assert.equal(Object.keys(result).length, 2);
  Assert.equal(result.id, DEVICE_ID);
  Assert.equal(result.name, DEVICE_NAME);

  try {
    await client.updateDevice(FAKE_SESSION_TOKEN, ERROR_ID, DEVICE_NAME);
    do_throw("Expected to catch an exception");
  } catch (unexpectedError) {
    Assert.equal(unexpectedError.code, 500);
  }

  await promiseStopServer(server);
});

add_task(async function test_getDeviceList() {
  let canReturnDevices;

  const server = httpd_setup({
    "/account/devices"function (request, response) {
      if (canReturnDevices) {
        response.setStatusLine(request.httpVersion, 200, "OK");
        response.bodyOutputStream.write("[]", 2);
      } else {
        response.setStatusLine(request.httpVersion, 500, "Alas");
        response.bodyOutputStream.write("{}", 2);
      }
    },
  });

  const client = new FxAccountsClient(server.baseURI);

  canReturnDevices = true;
  const result = await client.getDeviceList(FAKE_SESSION_TOKEN);
  Assert.ok(Array.isArray(result));
  Assert.equal(result.length, 0);

  try {
    canReturnDevices = false;
    await client.getDeviceList(FAKE_SESSION_TOKEN);
    do_throw("Expected to catch an exception");
  } catch (unexpectedError) {
    Assert.equal(unexpectedError.code, 500);
  }

  await promiseStopServer(server);
});

add_task(async function test_client_metrics() {
  function writeResp(response, msg) {
    if (typeof msg === "object") {
      msg = JSON.stringify(msg);
    }
    response.bodyOutputStream.write(msg, msg.length);
  }

  let server = httpd_setup({
    "/session/destroy"function (request, response) {
      response.setHeader("Content-Type""application/json; charset=utf-8");
      response.setStatusLine(request.httpVersion, 401, "Unauthorized");
      writeResp(response, {
        error: "invalid authentication timestamp",
        code: 401,
        errno: 111,
      });
    },
  });

  let client = new FxAccountsClient(server.baseURI);

  await Assert.rejects(
    client.signOut(FAKE_SESSION_TOKEN, {
      service: "sync",
    }),
    function (err) {
      return err.errno == 111;
    }
  );

  await promiseStopServer(server);
});

add_task(async function test_email_case() {
  let canonicalEmail = "greta.garbo@gmail.com";
  let clientEmail = "Greta.Garbo@gmail.COM";
  let attempts = 0;

  function writeResp(response, msg) {
    if (typeof msg === "object") {
      msg = JSON.stringify(msg);
    }
    response.bodyOutputStream.write(msg, msg.length);
  }

  let server = httpd_setup({
    "/account/login"function (request, response) {
      response.setHeader("Content-Type""application/json; charset=utf-8");
      attempts += 1;
      if (attempts > 2) {
        response.setStatusLine(
          request.httpVersion,
          429,
          "Sorry, you had your chance"
        );
        return writeResp(response, "");
      }

      let body = CommonUtils.readBytesFromInputStream(request.bodyInputStream);
      let jsonBody = JSON.parse(body);
      let email = jsonBody.email;

      // If the client has the wrong case on the email, we return a 400, with
      // the capitalization of the email as saved in the accounts database.
      if (email == canonicalEmail) {
        response.setStatusLine(request.httpVersion, 200, "Yay");
        return writeResp(response, { areWeHappy: "yes" });
      }

      response.setStatusLine(request.httpVersion, 400, "Incorrect email case");
      return writeResp(response, {
        code: 400,
        errno: 120,
        error: "Incorrect email case",
        email: canonicalEmail,
      });
    },
  });

  let client = new FxAccountsClient(server.baseURI);

  let result = await client.signIn(clientEmail, "123456");
  Assert.equal(result.areWeHappy, "yes");
  Assert.equal(attempts, 2);

  await promiseStopServer(server);
});

// turn formatted test vectors into normal hex strings
function h(hexStr) {
  return hexStr.replace(/\s+/g, "");
}

Messung V0.5
C=95 H=95 G=94

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.9Bemerkung:  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.