Skip to content

Commit 193b9e0

Browse files
committed
removed default for persistence in outbound security module. Default was presumptuous.
1 parent 176c989 commit 193b9e0

5 files changed

Lines changed: 45 additions & 11 deletions

File tree

example_import/reset_state.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
# Reset the state of the example_import project
3+
rm terraform.tfstate
4+
rm terraform.tfstate.backup
5+
rm -rf .terraform.lock.hcl
6+
terraform init -upgrade

example_import/smart_auth_imported.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ resource "smilecdr_smart_outbound_security" "smart_auth" {
2222
davinci_native_consent_handling = false
2323
smart_callback_post_authorize_script_text = local.post_authorize_callback
2424
dependency_local_inbound_security = "SECURITY_IN_UP"
25-
dependency_fhir_persistence_module = "PERSISTENCE_ALL"
2625
}

provider/resource_smart_outbound_security.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,6 @@ func resourceSmartOutboundSecurity() *schema.Resource {
519519
"dependency_fhir_persistence_module": {
520520
Type: schema.TypeString,
521521
Optional: true,
522-
Default: "PERSISTANCE_ALL",
523522
Description: "The FHIR Storage module to associate with this module.",
524523
},
525524
"dependency_saml_authentication_module": {
@@ -862,6 +861,7 @@ func smartOutboundSecurityResourceToModuleConfig(d *schema.ResourceData) (*smile
862861
})
863862
}
864863
if v, ok := d.GetOk("smart_callback_post_authorize_script_text"); ok {
864+
fmt.Printf("smart_callback_post_authorize_script_text: %s\n", v.(string))
865865
moduleConfig.Options = append(moduleConfig.Options, smilecdr.ModuleOption{
866866
Key: "post_authorize_script.text",
867867
Value: v.(string),

smilecdr/client.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ func (c *Client) Get(ctx context.Context, endpoint string) ([]byte, error) {
7070
return nil, err
7171
}
7272

73-
body, err := io.ReadAll(resp.Body)
73+
rBody, err := io.ReadAll(resp.Body)
74+
7475
if err != nil {
7576
errMsg := fmt.Sprintf("Http GET: error reading Response Body: %s", err.Error())
7677
tflog.Error(ctx, errMsg)
7778
return nil, err
7879
}
7980

80-
return body, nil
81+
return rBody, nil
8182
}
8283

8384
func (c *Client) Post(ctx context.Context, endpoint string, body []byte) ([]byte, error) {
@@ -107,14 +108,16 @@ func (c *Client) Post(ctx context.Context, endpoint string, body []byte) ([]byte
107108
return nil, err
108109
}
109110

110-
body, err = io.ReadAll(resp.Body)
111+
var rBody []byte = nil
112+
113+
rBody, err = io.ReadAll(resp.Body)
111114
if err != nil {
112115
errMsg := fmt.Sprintf("Http POST: Error reading Response Body: %s", err)
113116
tflog.Info(ctx, errMsg)
114117
return nil, err
115118
}
116119

117-
return body, nil
120+
return rBody, nil
118121
}
119122

120123
func (c *Client) Put(ctx context.Context, endpoint string, body []byte) ([]byte, error) {
@@ -144,13 +147,15 @@ func (c *Client) Put(ctx context.Context, endpoint string, body []byte) ([]byte,
144147
return nil, err
145148
}
146149

147-
body, err = io.ReadAll(resp.Body)
150+
var rBody []byte = nil
151+
152+
rBody, err = io.ReadAll(resp.Body)
148153
if err != nil {
149154
fmt.Printf("[ERROR] Http PUT: Error reading Response Body: %s", err.Error())
150155
return nil, err
151156
}
152157

153-
return body, nil
158+
return rBody, nil
154159
}
155160

156161
func (c *Client) Delete(ctx context.Context, endpoint string) ([]byte, error) {
@@ -177,11 +182,11 @@ func (c *Client) Delete(ctx context.Context, endpoint string) ([]byte, error) {
177182
return nil, err
178183
}
179184

180-
body, err := io.ReadAll(resp.Body)
185+
rBody, err := io.ReadAll(resp.Body)
181186
if err != nil {
182187
fmt.Println("[ERROR] Http DELETE: Error reading Response Body:", err)
183188
return nil, err
184189
}
185190

186-
return body, nil
191+
return rBody, nil
187192
}

smilecdr/module_config.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ type ModuleConfig struct {
2626
Dependencies []ModuleDependency `json:"dependencies,omitempty"`
2727
}
2828

29+
func printModuleConfig(moduleConfig ModuleConfig) {
30+
fmt.Println("ModuleConfig:")
31+
fmt.Println(" ModuleId: ", moduleConfig.ModuleId)
32+
fmt.Println(" ModuleType: ", moduleConfig.ModuleType)
33+
fmt.Println(" Options:")
34+
for _, kv := range moduleConfig.Options {
35+
fmt.Println(" ", kv.Key, ": ", kv.Value)
36+
}
37+
fmt.Println(" Dependencies:")
38+
for _, dep := range moduleConfig.Dependencies {
39+
fmt.Println(" ", dep.ModuleId, ": ", dep.Type)
40+
}
41+
}
42+
2943
func (moduleConfig *ModuleConfig) LookupOptionOk(key string) (string, bool) {
3044

3145
moduleConfigOptions := moduleConfig.Options
@@ -94,9 +108,19 @@ func (smilecdr *Client) PutModuleConfig(ctx context.Context, nodeId string, modu
94108
var moduleId = module.ModuleId
95109

96110
var endpoint = fmt.Sprintf("/module-config/%s/%s/set", nodeId, moduleId)
97-
jsonBody, _ := json.Marshal(module)
111+
112+
printModuleConfig(module) // DEBUG
113+
114+
jsonBody, error := json.Marshal(module)
115+
if error != nil {
116+
fmt.Println("error marshalling moduleConfig:", error)
117+
return module, error
118+
}
119+
120+
fmt.Println("PutModuleConfig: ", string(jsonBody))
98121

99122
resp, putErr := smilecdr.Put(ctx, endpoint, jsonBody)
123+
100124
if putErr != nil {
101125
fmt.Println("error during Put in PutModuleConfig:", putErr)
102126
fmt.Println("ResponseBody:", string(resp))

0 commit comments

Comments
 (0)