Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak1556 committed Dec 7, 2016
1 parent 0670178 commit cbddbdb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
16 changes: 14 additions & 2 deletions atom/browser/api/atom_api_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,24 @@ void OnClientCertificateSelected(
v8::Isolate* isolate,
std::shared_ptr<content::ClientCertificateDelegate> delegate,
mate::Arguments* args) {
mate::Dictionary cert_data;
if (!args->GetNext(&cert_data)) {
if (args->Length() == 2) {
delegate->ContinueWithCertificate(nullptr);
return;
}

v8::Local<v8::Value> val;
args->GetNext(&val);
if (val->IsNull()) {
delegate->ContinueWithCertificate(nullptr);
return;
}

mate::Dictionary cert_data;
if (!mate::ConvertFromV8(isolate, val, &cert_data)) {
args->ThrowError("Must pass valid certificate object.");
return;
}

std::string data;
if (!cert_data.Get("data", &data))
return;
Expand Down
10 changes: 10 additions & 0 deletions spec/api-app-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ describe('app module', function () {
done()
})

ipcRenderer.once('select-client-certificate', function (event, webContentsId, list) {
assert.equal(webContentsId, w.webContents.id)
assert.equal(list.length, 1)
assert.equal(list[0].issuerName, 'Intermediate CA')
assert.equal(list[0].subjectName, 'Client Cert')
assert.equal(list[0].issuer.commonName, 'Intermediate CA')
assert.equal(list[0].subject.commonName, 'Client Cert')
event.sender.send('client-certificate-response', list[0])
})

app.importCertificate(options, function (result) {
assert(!result)
ipcRenderer.sendSync('set-client-certificate-option', false)
Expand Down
11 changes: 4 additions & 7 deletions spec/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const protocol = electron.protocol
const v8 = require('v8')

const Coverage = require('electabul').Coverage
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const url = require('url')
Expand Down Expand Up @@ -192,12 +191,10 @@ ipcMain.on('set-client-certificate-option', function (event, skip) {
if (skip) {
callback()
} else {
assert.equal(list.length, 1)
assert.equal(list[0].issuerName, 'Intermediate CA')
assert.equal(list[0].subjectName, 'Client Cert')
assert.equal(list[0].issuer.commonName, 'Intermediate CA')
assert.equal(list[0].subject.commonName, 'Client Cert')
callback(list[0])
ipcMain.on('client-certificate-response', function (event, certificate) {
callback(certificate)
})
window.webContents.send('select-client-certificate', webContents.id, list)
}
})
event.returnValue = 'done'
Expand Down

0 comments on commit cbddbdb

Please sign in to comment.