Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat(config-http): return error if value is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Aug 24, 2016
1 parent 5f02303 commit f7a668d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/http-api/resources/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ exports.getOrSet = {
const key = request.pre.args.key
const value = request.pre.args.value

if (typeof value === 'object' && value.type === 'Buffer') {
return reply({
Message: 'Invalid value type',
Code: 0
}).code(500)
}

if (value === undefined) {
// Get the value of a given key
return request.server.app.ipfs.config.get((err, config) => {
Expand Down
20 changes: 20 additions & 0 deletions test/http-api/interface-ipfs-core-over-ipfs-api/test-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-env mocha */

'use strict'

const test = require('interface-ipfs-core')
const FactoryClient = require('./../../utils/factory-http')

let fc

const common = {
setup: function (callback) {
fc = new FactoryClient()
callback(null, fc)
},
teardown: function (callback) {
fc.dismantle(callback)
}
}

test.config(common)

0 comments on commit f7a668d

Please sign in to comment.