Skip to content

Commit

Permalink
Merge pull request #529 from buglinjo/patch-1
Browse files Browse the repository at this point in the history
Adding support of global bearer token variable.
  • Loading branch information
shalvah authored Oct 15, 2022
2 parents 377eb64 + 3d3b343 commit 6bc3487
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/Writing/PostmanCollectionWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ protected function generateAuthObject(): array
],
"bearer" => [
'type' => 'bearer',
'bearer' => [
[
'key' => $this->config->get('auth.name'),
'value' => $this->config->get('auth.use_value'),
'type' => 'string',
],
],
],
default => [
'type' => 'apikey',
Expand Down
11 changes: 9 additions & 2 deletions tests/Fixtures/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,13 @@
}
],
"auth": {
"type": "bearer"
"type": "bearer",
"bearer": [
{
"key": "key",
"value": null,
"type": "string"
}
]
}
}
}
13 changes: 12 additions & 1 deletion tests/Unit/PostmanCollectionWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,18 @@ public function auth_info_is_added_correctly()
$config['auth']['in'] = 'bearer';
$collection = $this->generate($config, [$endpoints]);

$this->assertEquals(['type' => 'bearer'], $collection['auth']);
$expected = [
'type' => 'bearer',
'bearer' => [
[
'key' => null,
'value' => null,
'type' => 'string',
],
],
];

$this->assertEquals($expected, $collection['auth']);
$this->assertArrayNotHasKey('auth', $collection['item'][0]['item'][0]['request']);
$this->assertEquals(['type' => 'noauth'], $collection['item'][0]['item'][1]['request']['auth']);

Expand Down

0 comments on commit 6bc3487

Please sign in to comment.